Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #43163

Re: coding dynamic allocation question

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: coding dynamic allocation question
Date 2014-04-19 20:18 -0700
Organization None to speak of
Message-ID <lnbnvw3cz9.fsf@nuthaus.mib.org> (permalink)
References (4 earlier) <liv5fj$v5i$1@dont-email.me> <lnk3ak3gt0.fsf@nuthaus.mib.org> <liv9lu$lo5$1@dont-email.me> <lnfvl83fq6.fsf@nuthaus.mib.org> <livcfj$2in$1@dont-email.me>

Show all headers | View raw


"Bill Cunningham" <nospam@nspam.invalid> writes:
> "Keith Thompson" <kst-u@mib.org> wrote in message
>> Passing by value is how C passes parameters to functions.  The value of
>> the argument expression is passed to the function.  If the argument is a
>> variable name, the function doesn't have access to the variable, just to
>> the value it had when the call was executed.  And again, no, it doesn't
>> involve pointer manipulation, just copying a value.
>>
>> The term applies only to function calls.
>
>     Ok. That makes sense except for this one thing. Strings. How are they 
> pass by value? When I think of "value" I am thinking about numerical values. 
> For example...
>
> char *val;
> val="I am a string.";
>
> Pass that val to a function with a paramter of say
>
> void func(char *value);
>
> How is that still pass by value? It's a string. Just a little confused by 
> that. The ints, doubles, float and such makes sense.

val is an object of type char*.  The value of that object (which happens
to be a pointer) is passed to func.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

coding dynamic allocation question "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-18 22:25 -0400
  Re: coding dynamic allocation question Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-19 04:06 -0700
    Re: coding dynamic allocation question "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-19 19:04 -0400
      Re: coding dynamic allocation question Barry Schwarz <schwarzb@dqel.com> - 2014-04-19 16:52 -0700
      Re: coding dynamic allocation question Keith Thompson <kst-u@mib.org> - 2014-04-19 17:36 -0700
        Re: coding dynamic allocation question "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-19 20:47 -0400
          Re: coding dynamic allocation question Keith Thompson <kst-u@mib.org> - 2014-04-19 18:55 -0700
            Re: coding dynamic allocation question "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-19 21:59 -0400
              Re: coding dynamic allocation question Keith Thompson <kst-u@mib.org> - 2014-04-19 19:19 -0700
                Re: coding dynamic allocation question "Bill Cunningham" <nospam@nspam.invalid> - 2014-04-19 22:47 -0400
                Re: coding dynamic allocation question Keith Thompson <kst-u@mib.org> - 2014-04-19 20:18 -0700
              Re: coding dynamic allocation question Richard <rgrdev_@gmail.com> - 2014-04-20 11:00 +0100
      Re: coding dynamic allocation question rescattered@gmail.com - 2014-04-20 05:25 -0700
        Re: coding dynamic allocation question rescattered@gmail.com - 2014-04-20 05:42 -0700
  Re: coding dynamic allocation question Richard <rgrdev_@gmail.com> - 2014-04-19 14:57 +0100
    Re: coding dynamic allocation question Ian Collins <ian-news@hotmail.com> - 2014-04-20 23:24 +1200
  Re: coding dynamic allocation question Michael Angelo Ravera <maravera@prodigy.net> - 2014-04-19 16:19 -0700

csiph-web