Hello Victor,
15 Jan 98, Victor Kemp of 3:771/340 wrote to All
VK> Hi, maybe that last char to char * question I asked in this
VK> echo was so simple that no-body bothered to reply.
Patience, patience...
VK> Anyway I need to append a char onto the end of a string,
VK> something like this
VK> char stringvar[90];
VK> char charvar;
VK> strcat(stringvar, charvar);
VK> But that doesn't work, someone please tell me how it's done.
Hmm, as often there are more ways than one to do this.
A quick and dirty way would be using a temp char array like:
char temp[1]=" "; // to get the trailing '\0' in place.
temp[0] = charvar;
strcat( stringvar, temp );
If you're more adventurous, you could write a function for this like:
int charadd( char *dest, const char ch, int length );
{
int len = strlen(dest);
if( len < lenght-1 )
{ dest[len] = ch; dest[len+1] = '\0'; }
else return 0; // buffer full
return 1; // char added
}
Hope this gave you some idea...
Greetings from overcast Amsterdam,
Jan
email:bijster@worldonline.nl
http://home.worldonline.nl/~bijster
--- MBM v3.41e
---------------
* Origin: Snuffelaar bij DosBoss West (2:500/121.5122)
|