| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | puts() |
Hi Robin, You wrote to me: RS> FT> If the function prototype for puts() is: RS> FT> int puts(const char *s); RS> FT> how can it print the following parameter: RS> FT> puts( "Hello world from puts!" ); RS> FT> which is not the value of a pointer to char? RS> GW> In this case it is, as in C anything other than an integral data type RS> GW> is passed by reference. So in the puts() call the address of the start RS> GW> of the string "Hello world from puts!" is used, which is a "const char RS> GW> *" 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. :) If you want to look at it that way, you're welcome. I find it confusing, so don't expect me to agree with you. As I interpret and describe C data transfer to functions:- a) If data is passed by value then there is no direct way of changing the original data from within the function. b) If data is passed by reference (a pointer to the data) then the original data can be modified from within the function. As a result as strings are manipulable directly from within the function I describe than as passed by reference. George * SLMR 2.1a * Wishing you a Happy Christmas and a Peaceful 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™.