hello,
i am tinkering with some code that stores a pattern of characters into an array of 20x60, found from the standard input stream (basically a text file with characters on eachline 20x60 at the end of each line is a line break). i cannot get the program to print the text file when i execute and redirect a text file to the executable. can anyone help me out or let me know of some suggestions in the code i can make?
thanks!
Code:#include <stdio.h> #include <stdlib.h> #define ROWS 20 #define COLS 60 int main() { int i, j, r, c; // indexers char cell[ROWS][COLS]; // the pattern char value; // from input stream for( r = 0; r < ROWS; ++r) { c = 0; while( (value = getchar() ) != '\n') { cell[r][c++] = value; // store X or O } } putchar('\n'); for( i = 0; i < ROWS; ++i ) { for( j = 0; j < COLS; ++j ) putchar(cell[i][j]); putchar('\n'); } putchar('\n'); return 0; }



LinkBack URL
About LinkBacks


