Hi Victor,
You asked:
VK>Hi, how do you convert a char to a string?
VK>I would like to concatenate a single char onto the end of a
VK>string but it says it can't convert int to char * when I do
VK>this:
VK> char charvar;
VK> char stringvar[90];
VK> strcat(stringvar, charvar);
The error message is correct, it is an illegal operation.
VK>I also tried doing:
VK> strcat(stringvar, (char *)charvar);
VK>but that made a big mess of things although gave no error message.
Hmm. That can provide new and interesting ways of crashing things.
The most obvious way of doing it is:
int string_offset;
string_offset = strlen (stringvar); /* Get end of string */
stringvar[string_offset] = charvar; /* Stuff the character in */
stringvar[++string_offset] = 0; /* add terminator */
George
* SLMR 2.1a * All Trademarks acknowledged (just in case ).
--- Maximus/2 3.01
---------------
* Origin: DoNoR/2,Woking UK (44-1483-717905) (2:440/4)
|