TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: VICTOR KEMP
from: JAN BIJSTERBOSCH
date: 1998-01-16 19:56:00
subject: char to string

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.