??? 05/22/04 18:22 Read: times |
#70964 - RE: Another stringy problem Responding to: ???'s previous message |
Jez Smith said:
So my question now would be if I have defined char string_name; and i called my function with foo(string_name,1) what would be passed to the function? string_name's current value. The compiler/linker will have allocated a single byte location and associated the variable name 'string_name' with that location. In C, parameters are passed by value only, so foo()'s str parameter would be set with the value held in the byte location associated with string_name at the point of function invocation. If you also changed foo()'s str parameter to be a 'char *', this is still very likely not what you want. If you want to call foo() with string_name's value, change the str parameter's type to 'char'. If you want to call foo() with string_name's address, change the str parameter's type to 'char *' and change the statement calling foo() to 'foo(&string_name,1)'. |
Topic | Author | Date |
Another stringy problem | 01/01/70 00:00 | |
RE: Another stringy problem | 01/01/70 00:00 | |
RE: Another stringy problem | 01/01/70 00:00 | |
RE: Another stringy problem | 01/01/70 00:00 | |
RE: Another stringy problem | 01/01/70 00:00 | |
RE: Another stringy problem![]() | 01/01/70 00:00 |