Here str2
is a string I need to append and str1
is the string I append onto str2
. After I append last to str2
I need to append a number (int cnt
) to str2
. So I am using the below code, which came to my mind and it is working. Is it wrong to code like this, since I saw the usage of string s = lexical_cast<string>(a);
and itoa (i,buffer,10);
implementations where compiler complaints about the library.
string str2;
string str1;
int cnt;
str2 += str1 ;
str2 += char(cnt+48);//cnt converted to ASCII char and appended;