Jun 13, 2012 at 11:40am Jun 13, 2012 at 11:40am UTC
I have a
1 2 3 4
int a=10; //or let's say int=9;
//and combine it to a ".txt" using strcat
strcat(a,".txt" );
I already tried using
1 2 3 4 5 6
int a=10;
string h;
h=a;
strcat(h.c_str(),".txt" );
But there's a error after compiling..
cannot convert parameter 1 from 'const char *' to 'char *'
I still need to retain integer 10, 9, 100 to '10', '9', '100' and not converting it to symbols and letters, etc..
what else can I do?
Last edited on Jun 13, 2012 at 11:45am Jun 13, 2012 at 11:45am UTC
Jun 13, 2012 at 11:48am Jun 13, 2012 at 11:48am UTC
Last edited on Jun 13, 2012 at 11:49am Jun 13, 2012 at 11:49am UTC
Jun 13, 2012 at 12:16pm Jun 13, 2012 at 12:16pm UTC
Use _itoa to store your charized 10 into a temporary buffer, then add it to your string. Don't ever use stdio functions with C++ strings. Especially strcat. Buffer Overflow/Seg Fault may happen.