I have a string as - "Id is %d" and an integer as 1000. I want a final string as - "Id is 1000".
I tried like this -
the output is - Id is %d 1000.
How can I fit this integer into the string?
I tried like this -
Code:
char* temp = "id is %d"; int id = 1000; char* temp1 = new char[20]; memset(temp1, '\0', 20); sprintf(temp1, "%s %d", temp, id); cout << temp1 << endl;
How can I fit this integer into the string?
Comment