TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Kurt Kuzba
from: George White
date: 1998-12-31 09:19:04
subject: puts()

KK>GW>   As I interpret and describe C data transfer to functions:-
KK>GW>   a) If data is passed by value then there is no direct way
KK>GW>      of changing the original data from within the function.
KK>GW>   b) If data is passed by reference (a pointer to the data)
KK>GW>      then the original data can be modified from within the
KK>GW>      function.
KK>GW>   As a result as strings are manipulable directly from
KK>GW>   within the function I describe than as passed by
KK>GW>   reference.
KK>   That's fine, for personal conprehension, as long as you
KK>   know that only values are passed in C. In the case of
KK>   a pointer, the value of the pointer is passed, and you
KK>   may use that pointer to access the data to which it
KK>   points by dereferencing it. There is some confusion when
KK>   you involve a wider range of languages. In BASIC, for
KK>   instance, you pass by reference and the called function
KK>   has a variable which is an alias for the passed variable.
KK>   C++ also has such an ability. In such cases, your local
KK>   variable in the called function IS the passed variable,
KK>   and the called function now has that variable in scope.

See reply to Gerry Danen.

Its essentially down to the fact that a string is an array, and arrays
are passed by a pointer to the data (yes indeed the pointer has a value,
and manipulating it doesn't affect any original of it [but anyway it's
usually compiler generated so there isn't an ogiginal variable to
modify] but it's not the data, so I've said strings are passed by
reference not value) and as strings are special cases of arrays and
string functions take pointer arguments, when strings are passed to
functions and manipulated the original string data is modified, not a
copy thereof.

I'll drop further discussion on this matter as if we're not careful it
could easily end up as futile repetative messages.

George

 * SLMR 2.1a * Wishing you a Peaceful and Prosperous New Year

--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4)
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: 440/4 255/1 251/25 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™.