Mail Archives: djgpp/1998/02/08/16:32:10
In article <34DE1449 DOT 185C AT bellsouth DOT net> you wrote:
: Im tring to insert the num rturned by getpid(unix sytem call) into a
: string. cna someone tell me how to do this if the
: int is Mypid and the ptr to the string is *str.
I think itoa() (the int to ascii function) should do the trick.
You can try the following:
str = itoa(Mypid);
You may encounter a problem is Mypid is not a one digit integer.
If this is the case, you will want to make sure *str is a char string
and try this little nifty code left over from the original C language:
sprintf(str, "%d", Mypid);
The sprintf command is just like the printf command, but instead of
printing the output to the screen (stdout), it prints it to a char
string (in this case, str) for later use.
(Also note that the sprintf function is useful for concatenating
many variables of different types into one character string.)
Hope this helps.
Jean-Luc Romano
- Raw text -