/* * printer.c * * Computer Science 50, Fall 2011 * section6 * * Practice with structs. */ #include int main(void) { // open a new document FILE *fp = fopen("doc.txt", "r"); // check for successful open if (fp == NULL) { printf("Could not open file.\n"); return 1; } // store each line of text char output[256]; // get text from user and save to file for(int i = 1; fgets(output, sizeof(output), fp) != NULL; i++) printf("Line %02d: %s", i, output); // close the file fclose(fp); // success return 0; }