Thanks for presenting two different methods to do this. I got stringstreams working in a test program, but sprintf causes some wierd characters instead of letters to be entered in the string and it changes the console font permanently so I have to restart it.
Code:
#include <iostream>
using namespace std;
int main()
{
int value = 7;
char title[8] = "balance";
char list[256];
strcat(list, title);
strcat(list, " ");
sprintf(&list[strlen(list)], "%d", value);
cout << list << endl;
}
This program outputs "ŒÏ@•@õÿ¿" and then "balance", but in a font that looks like ncurses borders and such, and it changes the command prompt after the program is done. What am I doing wrong?
If someone could point me to where I can read a basic explanation of printf and stringstreams that would be helpful. I like to understand the functions I use when I'm using them.