> >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?
> You can't pass by value, strictly speaking, but if it's a const char* its 
> contents can't be modified anyway, so why would you need to?
> 
> To convert to const char*, you can just cast directly:
> 
> char myString[6];
> 
> APICall( (const char*)myString );

  (const char *) = pass the string by value.. 

  ie:

    StrCopy(str, "Hello");
    APICall(str);

  this will put the pointer value of "str" on the stack, that is pushing
  one 4byte integer (the pointer)

    APICall("Hello");

  will put the data "Hello\0" on the stack. thus, pushing the string by
  value.. :)) just type casting it wont do the job :))

  cheers

az. 
--
Aaron Ardiri 
Java Certified Programmer      http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN       
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 656 1143           A/H: +46 8 668 78 72

if you enjoy it, then it aint work :) - rule #106 of life


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to