Is possible to read from a txt file in loop like this?
files names: input_1, input_2, …, input_20, the “k” in “input_k” is ment as variable.
for ( int k=0; k<20; k++ ){
fr = fopen("input_k", "r"){
for ( int i=0; i<width; i++ ){
for ( int j=0; i<height; i++ ){
fscanf( fr, "%d", &input_k[i*width+j] );
}
}
}
fclose(fw);
}
I think something like this is what you are aiming for, which will work with C89, C99, and beyond:
However, I’m making a number of assumptions about your intentions here, so this may not be what you really want.
EDIT
Fixed some typos, got rid of
widthandheightvariables.