Thank you for all the reply. Now I've a better understanding of char *.
One more question:
Void myFunction(char *message)
myFunction("my static message");
// above function call is pretty straight forward. But what if I need
to pass non static message to it? Is there a way to do it without
having to create a char * or char  variable. Something like this (I
know the syntax is not correct):
myFunction("my static message" + myInt);
Or do I have to do
sprintf(myMessage, "my non Static message %i", myInt);
Behalf Of Lim Hock-Chai
Sent: Wednesday, June 11, 2008 4:36 PM
To: C programming iSeries / AS400
Subject: [C400-L] basic c question about char *
can somebody help me understand how char * work?
char * s1;
s1 = "assign a value";
s1 = "assign another value"; //does c auto deallocate storage and
reallocate a longer one for this assignment?
. . .
char * s1
int myInt = 10;
sprintf(s1, "test %i", myInt); //why is s1 contains *null after this
This is the C programming iSeries / AS400 (C400-L) mailing list To post
a message email: C400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
As an Amazon Associate we earn from qualifying purchases.