cin problem

when we use cin>>
the - in the output jump one line down
i dont want it.for example i want to cin these by keyboard
1 2 3
4 5 6
4 2 3
what can i do?
Not sure I fully understand you. Do you want to enter the variables in the console window on the same line?

cin >> a >> b >> c?
1
2
3
4
5
6
7
8
//gotoxy using windows.h
void gotoxy (int x, int y) {
    COORD coord; // coordinates
    coord.X = x; // X and Y coordinates
    coord.Y = y;
    // moves to the coordinates
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
It might help if you showed us your code...
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
cin>>A[i][j];
}

in the output when you cin numbers they come in this form:
1
2
3
4
1
2
3
4
1
2
3
4
but i want to cin in this form:
1 2 3 4
1 2 3 4
1 2 3 4
with a \t between numbers...
I don't see a problem here. Consider this example:

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
26
27
28
29
30
#include <iostream>
using namespace std;

int main()
{
    int array[6];
    int i;

    cout << "enter 6 ints:" << endl;

    for (i=0; i<6; i++)
    {
        cin >> array[i];
    }

    cout << "you entered:" << endl;

    for (i=0; i<6; i++)
    {
        cout << array[i] << ' ';
    }

    cout << endl;

    
    cout << "hit enter to quit...";
    cin.get();
    cin.get();
    return 0;
}


I ran it several times entering the ints in different ways like:

enter 6 ints:
1
2
3
4
5
6
you entered:
1 2 3 4 5 6 
hit enter to quit...
enter 6 ints:
1 2
3 4
5 6
you entered:
1 2 3 4 5 6 
hit enter to quit...
enter 6 ints:
1 2 3
4 5 6
you entered:
1 2 3 4 5 6 
hit enter to quit...
enter 6 ints:
1 2 3 4 5 6
you entered:
1 2 3 4 5 6 
hit enter to quit...
enter 6 ints:
1 2 3
4 5
6
you entered:
1 2 3 4 5 6 
hit enter to quit...
@a friend:
cin<< will seperate inputs by spaces, so basically you don't need to change anything in your code to type in stuff like that.
Topic archived. No new replies allowed.