Storing characters in a var.

Working on code for a computer science class, i was wondering if some one could help me with line 18 - 19 of this

how do i make my code read the variables 1 2 3 4 5 6 <--- i.e read in 6 numbers from a person in the format of the following

Enter six digits of first number ( each seperated by a blank); 0 -2 3 1 0 1

Something to that effect.

Note this is our first C++ project and we are first year students, using loops - if statements = a hard no.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
3  using namespace std;
4
5  int main()
6  {
7      int age;
8      int number1, number2, number3, number4, number5, number6;
9      int number1_1, number2_2, number3_3, number4_4, number5_5, number6_6;
10     int deca_Number, decaNumber_2;
11     int mesoid_Sum, checkSum, deca_Number_Sum;
12
13     cout << "Welcome to planet RLLGRLYH(5). Ready to calculate..."
14          << endl
15          << "enter age: ";
16     cin >> age;
17     cout << endl;
18     cout << "Enter six digits of first number (each seperated by blank): ";
19     cin >> number1, number2, number3, number4, number5, number6;
20     cout << endl;
21
22     return 0;
Last edited on
Hello corestorm,

For line 19 you could do each variable separate, i.e., cin >> number1; and so on. Or chain all together: cin >> number1 >> number2 >> etc. As you can see using the comma is not working the way you thought it might.

Hope that helps,

Andy
I'll give that a try thanks Andy
Topic archived. No new replies allowed.