TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THOMAS HABETS
from: KURT KUZBA
date: 1998-02-03 07:27:00
subject: converting char to string

TH> TH>> char ch;
TH> TH>> char str[80];
TH> TH>> str[0] = ch;
TH> TH>> str[1] = 0;
TH> MB> 78 bytes wasted.
TH>   Ha....................ha.......................
   Since the initialization of a variable ensures that all
   members not specifically assigned a value will be assigned
   the value 0, one could do this, also:
char *CharCat(char *szStr, int iChar)
{
   char szTempStr[2] = "";
   szTempStr[0] = char(iChar);
   strcat(szStr, szTemp);
   return szStr;
}
   The use or creation of a string class would still allow all
   of this to go much quicker, since one could keep an int value
   denoting the present length of the string as a class member
   and append the new data at that point without having to look
   for the string terminator. A few clock cycles here and there
   in frequently used code will add up.
> ] A single step may begin a journey of 1,000 miles............
---
---------------
* Origin: *YOPS ]I[* 3.1 GIG * RA/FD/FE RADist * Milwaukee, WI (1:154/750)

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