How to print characters in rows and columns?

I need to print out characters in 6 rows and 5 columns, i got this code so far, when i run it it only print out the char in one column.

void printFile(){
string file= "proj1_test1.txt";
string a = " ";
char page[6][5]= {'A','B','C','D','E','F'};
cout << " What is the name of file to import?" << endl;
cin >> a;
if (a == file){
cout << "file successfully loaded" << endl;
for (int i = 0; i < 6; i++){
for (int j = 0; j < 5; j++){
cout << page [i][j] << " ";
}
cout << endl;
}
}
else{
cout << "The file " << a << " was not opened" << endl;
}
}
you can use http://www.cplusplus.com/reference/iomanip/setw/
or you can print using tabs << "\t text";

Of course you need some kind of counter to print a new line after each set.
Last edited on
Topic archived. No new replies allowed.