You can't pass an array (which is what a string is -- an array of char) by value
in C. C contains no notion of array length, which is something it would need if
it were to push it onto the stack.
If you need to modify the string in your subroutine but not alter the caller's
copy, you need to explicitly copy the string in the subroutine.
-- Keith
Steve <[EMAIL PROTECTED]> on 08/11/2000 04:25:46 PM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: Steve <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/US/PALM)
Subject: Forcing const char *
OK, my turn for a dumb C question. If I have a string variable, e.g.,
char myString[6], and then I have an API call which requires a const char
*x, how do I pass the variable myString in the function call to make it
be passed by value rather than by reference? I just can't seem to get
this right. So far the only thing I can get to work is to put the
constant "abcd" directly into the function call, but of course that's of
no interest if "abcd" needs to be changed from case to case.
Steve Patt
President, Stevens Creek Software
http://www.stevenscreek.com/palm
Best PQA ("ePQA"), PalmSource 99
Best Application ("PizzaScan"), Palm Developer's Conference 1998
First printing software for the Palm - September, 1997
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/