Reading and printing from a Text file

i am trying to read and print from a text file. This code only print one row instead of 5 rows. I have no clue now.
F
F
F
F
F
This is what i am getting but my text file contains
FFRRR
FFRRR
FFRRR
FFRRR
FFRRR
i NEED THIS OUTPUT...

#include <iostream>
#include <string>
#include<fstream>
using namespace std;
int main(){
ifstream file;
int rows = 6;
int col = 5;
// char page;
char file01;
char page[6][5];
file.open("proj1_test1.txt");
while(file >> file01){
for(int i = 0; i < rows; i++){
for(int j = 0; j < col; j++){
file >> page[i][j];
page[i][j] = file01;
}

// file.open("proj1_test1.txt");
cout << file01 << "\t";
cout << endl;
file.close();
}
}
return 0;
}
If you only want to read and print a file you can do it like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
  ifstream src(__FILE__);
  if (!src)
  {
    cerr << "Error opening file" << "\n\n";
    return 1;
  }
  string line;
  while (getline(src, line))
  {
    cout << line << "\n";
  }
}
Topic archived. No new replies allowed.