Hey, worlds worst programmer here. I have a question on using the string buffer as I'm having problems inputting two numbers on the same line. Now, with namespace std, I wouldn't have that problem. As I would usually use just the
cin >> x >> y;
cout << x << y;
And there would be no problem. Here is the code below.
The problem is that you ask for input for buf1 and buf2, but then you try to get more input for buf when you don't really need to.
29 30 31 32 33 34 35 36 37 38 39 40
//string buf; // Not needed
string buf1;
string buf2;
int x;
int y;
cout << "Enter two numbers on the same line and they will be outputted."<<endl;
cin >> buf1 >> buf2;
/*cin >> buf; x = atoi(buf.c_str());
cin >> buf; y = atoi(buf.c_str());*/
x = atoi(buf1.c_str());
y = atoi(buf2.c_str());
In any case, though, what's wrong with a simple cin >> x >> y;?
It does practically the same thing.