TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: VICTOR KEMP
from: ROGER SCUDDER
date: 1998-01-17 00:27:00
subject: char to string

Hello Victor.
15 Jan 98 15:38, Victor Kemp wrote to All:
VK> Anyway I need to append a char onto the end of a string, something like 
VK> 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.
 If the string length is known you can, assuming there is room
 in the array, assign the char to the last element +1 and then
 assign a nul just after...
 int len;
 len = strlen( stringvar );
 stringvar[ len ] = charvar;
 stringvar[ len + 1 ] = '\0';
 It is VERY important that you are sure there is enough room for
 all the characters.  One out of bounds array will crash your
 program quick!
 -Roger
... 'If it ain't broke, you can probably still fix it.' - Tim Allen
--- Msged 4.20 beta 2
(1:273/404@fidonet)
---------------
* Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA

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™.