TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: VICTOR KEMP
from: ADAM MAJER
date: 1998-01-16 17:54:00
subject: char to string

VK>Hi, maybe that last char to char * question I asked in this echo was so 
simp
VK>that no-body bothered to reply.
VK>Anyway I need to append a char onto the end of a string, 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.
You can't do that 'cause 'charvar' is not a pointer to a string but a
variable. Try something like
     int t = strlen(stringvar);
     stringvar[t++] = charvar;
     stringvar[t] = NULL;     <- need this for a string
You can't use
    strcat(stringvar,&charvar)
'cause charvar's pointer doesn't point to a NULL terminating string
(needs at least 2 bytes) but a single char.
 * SLMR 2.1a * hAS ANYONE SEEN MY cAPSLOCK KEY?
--- FMail 0.92
---------------
* Origin: The Programmer's Oasis on FIDONET! (1:348/203)

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