Writing chars from file into char 2D array

I need to write individual characters into a char 2D array. I initialized the array to all be 0s, and I've tried several methods to enter the chars into the array however when I try and cout anything I keep getting 0s or weird characters or blank lines. I believe the blank lines are the first space in the txt file, but every characters in the array becomes the space.


void Read(char bacteria[][COLS], int rows, fstream &simbac)
{
for(int row = 0; row < rows; row++)
{
for(int col = 0; col < COLS; col++)
bacteria[row][col] = '0';
}
for(int row = 0; row < rows; row++)
{
for(int col = 0; col < COLS; col++)
{
simbac >> bacteria[row][col];
cout << bacteria[row][col];
}
}

for(int row = 0; row < rows; row++)
{
for(int col = 0; col < COLS; col++)
cout << bacteria[row][col];
}
}
Topic archived. No new replies allowed.