in following code, i'm attempting store characters file (including newlines). if newline read, variable 'i' should incremented , 'j' reset 0, doesn't happen. i've confirmed newlines in fact being read , stored, printing array console.
void scan_solved_nonogram(board *b) { file *file = fopen("test.txt", "r"); int = 0, j = 0; while( ( b->symbol[i][j] = getc(file) ) != eof ) { j++; if( b->symbol[i][j] == '\n' ) { i++; j = 0; } } fclose(file); b->size_i = i; b->size_j = j; }
the problem increment j before check newline character.
while( ( b->symbol[i][j] = getc(file) ) != eof ) { j++;// increment j, need check newline @ j-1 if( b->symbol[i][j-1] == '\n' ) { i++; j = 0; } }
Comments
Post a Comment