Reading the next line of a file. (File Handling)(Arrays) ifstream

I need help in reading the next line of a file in CPlusPlus. Suppose this is the input file.
12345
67890
I want the output:
In array1 = 123
In array2 = 678
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  int array1[10], array2[10];
  int n, i=0;

  ifstream x;
  x.open("input.txt", ios::in)
  while( (!x.eof()) || (i<3) )
  {
    x >> n;
    array1[i] = n;
    i++;
  }
  //here should be the command for next line
  i = 0;
  while( (!x.eof()) || (i<3) )
  {
    x >> n;
    array2[i] = n;
    i++;
  }
  x.close();
http://www.cplusplus.com/reference/istream/istream/getline/
http://www.cplusplus.com/reference/istream/istream/ignore/
Use getline() to read 3 chars.
Use ignore() to skip ahead to the next newline.
Topic archived. No new replies allowed.