c - Copying each row of matrix to a temporary array -
i want copy row (one each team iterating) of 500x8 matrix temp array name actual_row. i've tried.
int matrix[500][8]; // has been filled int's int actual_row[8]; for(int = 0; < 500; i++) { for(int j = 0; j < 8; j++) { actual_row[j] = matrix[i][j]; printf("the row is: "); for(int q = 0; q < 8; q++) { printf(" %d ",actual_row[q]); // other stuff } } printf("\n"); } this not printing line, it's printing 0's , 1's sometime, there's i'm doing wrong.
in advance.
your logic off. need copy row actual_row, print contents. furthermore, why not print contents while copying matrix row actual_row:
printf("the row is: "); for(int j = 0; j < 8; j++) { actual_row[j] = matrix[i][j]; printf(" %d ",actual_row[j]); // other stuff } so code snippet should this:
int matrix[500][8]; // has been filled int's int actual_row[8]; for(int = 0; < 500; i++) { printf("the row is: "); for(int j = 0; j < 8; j++) { actual_row[j] = matrix[i][j]; printf(" %d ",actual_row[j]); // other stuff } // <--at point, actual_row contains row printf("\n"); }
Comments
Post a Comment