Reputation: 1
#include <iostream>
using namespace std;
void main(int argc, char* argv[])
{
int conversion, hash;
cout << "Select one." << endl;
cout << "0: Radix Method 32" << endl;
cout << "1: Radix Method 64" << endl;
cout << "2: SumUp" << endl;
cin >> conversion;
cout << endl << "Select one." << endl;
cout << "0: Division" << endl;
cout << "1: Multiplication" << endl;
cin >> hash;
cout << "Conversion: " + conversion << endl;
cout << "hash: " + hash << endl;
}
As simple as this is, I'm getting wild output. I feel like it's something obvious but I'm too tired to see it. The number I enter into the variables is the number of characters removed from the next output string. ex:
Select one.
0: Radix Method 32
1: Radix Method 64
2: SumUp
1
Select one.
0: Division
1: Multiplication
2
onversion:
sh:
Press any key to continue . . .
Select one.
0: Radix Method 32
1: Radix Method 64
2: SumUp
5
Select one.
0: Division
1: Multiplication
1
rsion:
ash:
Press any key to continue . . .
Am I crazy or does this make no sense? Am I using cin
wrong? I haven't used C++ for a few months, but I can't see anything wrong with it.
Upvotes: 0
Views: 124
Reputation: 75062
cout << "Conversion: " + conversion
means to print from conversion
elements after the head of the array.
You may want this (change +
to <<
):
cout << "Conversion: " << conversion << endl;
cout << "hash: " << hash << endl;
Upvotes: 2