i have a code like this:
int i = 123;
char myString[100];
strcpy(myString, "my text");
and how i want to add the 123 after "my text". how to do this in c/c++?
at the end myString
sould be my test123
i have a code like this:
int i = 123;
char myString[100];
strcpy(myString, "my text");
and how i want to add the 123 after "my text". how to do this in c/c++?
at the end myString
sould be my test123
In C++:
std::stringstream ss;
ss << "my text" << i;
std::string resultingString = ss.str();
There's no such thing as C/C++.
(To complement Luchian's answer)
In C:
char myString[128];
int i = 123;
snprintf(myString, sizeof(myString), "My Text %d", i);
Assuming mystring is large enough, which it is in this example:
sprintf( myString, "my text%d", 123 );
With the Qt QString object in C++:
std::cout << QString("my text %1").arg(123456);