Is it a fixed number of columns?
Code:
for( row = 0; row < ROWS; row++ )
{
if( fscanf( file, "%s", name[ row ] ) != 1 )
{
printf( "encountered an error reading file\n" );
/* do something here */
}
else
{
for( col = 0; col < COLS; col++ ) /* technically we are reading column 1, not column 0 */
{
if( fscanf( file "%d", &number[ row ][ col ] != 1 )
{
printf( "error reading number [ %d ][ %d ]\n", row, col );
/* do something here */
}
}
}
}
Now, in this example I am sticking the names from your first column into a different array than your numbers, which is why I said "technically we are reading column 1", but in the second array, it would fall as column 0, since arrays start at 0.
Quzah.