TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: VICTOR KEMP
from: LEE BRAIDEN
date: 1998-01-17 15:49:00
subject: RE:converting char to string

Hi Victor,
VK> Hi, how do you convert a char to a string?
VK>            char charvar;
VK>            char stringvar[90];
VK>            strcat(stringvar, charvar);
Add a function like:
char* chcat(char* str, char ch) {
  static char tmpstr[2]=" ";  /* create a 1-char + NUL string */
  tmpstr[0] = ch;             /* change the char to ch        */
  return strcat(str, tmpstr); /* append it to str and return  */
}
This still uses strcat for all the complicated stuff, and should be almost 
he
same in efficiency terms.  Once you've got this done, your example goes like:
char charvar;
char stringvar[90];
chcat(stringvar, chvar);
P.S.: I got this message in the C_PLUSPLUS area... if you're doing it in C++,
it's much easier - look up the String class in your manuals.
Later,
- Lee
---
Lee Braiden
FIDO: 2:443/777.3        EMail: lee.braiden@coole.piglets.com
--- FIPS/32 v0.98 W95/NT [Unreg]
---------------
* Origin: Oppression is nine tenths of the law (2:443/777.3)

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