TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: George White
from: Gerry Danen
date: 1998-12-28 12:24:38
subject: puts()

RS> Nope, it's still passed by value, since the argument the function
 RS> expects to receive is a pointer, in other words, the value of said
 RS> pointer. It's semantics, though I like to be able to say,
 RS> unequivocally, that C always passes by value. :)

While it's true what you say here, you're leaving out the pointers and
how one can manipulate data via the passed pointers.

 GW> If you want to look at it that way, you're welcome. I find it
 GW> confusing, so don't expect me to agree with you.

You're gonna have to, George. :)

 GW> As I interpret and describe C data transfer to functions:-

 GW> a) If data is passed by value then there is no direct way of changing
 GW> the original data from within the function.

 GW> b) If data is passed by reference (a pointer to the data) then the
 GW> original data can be modified from within the function.

Interpretation correct. :)

 GW> As a result as strings are manipulable directly from within the
 GW> function I describe than as passed by reference.

Nope. You can manipulate data only via the pointer passed, thus
indirectly. Get out your copy of Kernighan and Ritchie's "The C
Programming Language" and check page 202 (second edittion, almost
at the top), which says:

 "In preparation for the call to a function, a copy is made of each
 argument; all argument-passing is strictly by value. A function may
 change the values of its parameter objects, which are copies of the
 argument expressions, but these changes cannot affect the values of
 the arguments. However, it is possible to pass a pointer on the
 understanding that the function may change the value of the object to
 which the pointer points."

Just reading this paragraph by itself may be tough, so I often advise
someone getting into C programming to get a copy of this book and study
it. Available at univ and college bookstores.


Gerry Danen -- email gdanen{at}bigfoot.com -- ICQ 17897683
  --home page: http://www.geceventures.com
  --year 2000: http://www.geceventures.com/y2k.htm
1 year and 4 days until January 1, 2000.

--- Maximus 3.01
* Origin: Check CD-ROM offer on home page... (1:17/667.8)
SEEN-BY: 396/1 632/0 371 633/260 262 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 17/667 275/1 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.