/** * Read a file into a statically allocated array * @author gtowell * Created: Mar 2021 * **/ #include #include #include #define MAX_LINES 512 int main(int argc, char* argv[]) { // length of a line is guaranteed to be less than // half the number of lines in the text. char a[MAX_LINES][MAX_LINES/2+1]; FILE* f = fopen(argv[1], "r"); if (!f) { fprintf(stderr, "No such file\n"); return 1; } int linecount=0; // A while loop with no body!!! while (fgets(a[linecount++], MAX_LINES/2+1, f)); for (int i=0; i