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

Roger Scudder wrote in a message to Tom Torfs:
TT> Because it doesn't work. The char may or may not be followed by a
TT> nul-byte. Most likely it will not.
 RS>  Yeah, I didn't think it through.  I did some test's and it worked 
 RS> so I assumed it was OK.
If you defined the char as an int and you were running on a little-endian 
machine this will probably always seem to work.
 
TT> Try this instead:
TT> strncat(stringvar, &charvar, 1);
TT> Although I still doubt this is conforming code...
 RS>  I think I'll just stick to the method I used in my reply to the 
 RS> originator of the thread.
That's best, because the above won't work for non-lvalue chars.
greetings,
Tom
tomtorfs@village.uunet.be
--- timEd/2 1.10+
---------------
* Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516)

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