Groovy hepcat Roger Scudder jived with Eric Londaits on 20 Jan 98 09:16:19!
char to string's a cool scene. Dig it!
VK>> char stringvar[90];
VK>> char charvar;
EL> strcat takes *char as parameters... so try
EL> strcat(stringvar, &charvar);
RS> Very nice solution! I can't understand why I never see
RS> anyone using it.
I'll tell you why: because it's garbage. This will try to copy
characters until null ('\0') is found. But since charvar is only a
single byte, and because there's no way of knowing what is in memory
directly after that one byte, and because some OS chuck a wobly if you
access memory that doesn't belong to you, this will result in
undefined behaviour. Anithing could happen!
Now, I've already given you a couple of solutions, so I won't bother
reiterating. But one of my solutions was to use strncat() instead of
strcat(). Think about that.
Wolvaen
... What else do they call you besides Jamima... and smartass? - Eastwood
--- Blue Wave/RA v2.20
---------------
* Origin: The Gate, Melbourne Australia, +61-3-9809-5097 33.6k (3:633/159)
|