Program only works with single digit numbers

Program only works correctly with single digit numbers. When I enter numbers with more than one digit, the second input is skipped. Please help!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>
#include<string>

using namespace std;

string number1;
string number2;

int main()
{

for (int j = 0; j<100; j++)
   {
        cout << "Please enter a number: ";
        cin >> number1[j];
        cout << "Please enter a second number: ";
        cin >> number2[j];
        cout << number1[j] << endl;
        cout << number2[j] << endl;
        if(number1[j]=='1'){
            cout << "SUCCESS" << endl;
        }
    }
}
When I enter numbers with more than one digit, the second input is skipped.

that's because number1[j] can only hold one element but that said your program does look a bit strange to me. what exactly are you trying to do?
Topic archived. No new replies allowed.