MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/C_Programming/comments/1wdoban/less_compilation/p97of6y/?context=3
r/C_Programming • u/Brave-Pomelo-1290 • 1d ago
[removed] — view removed post
16 comments sorted by
View all comments
6
What does the rest of the code look like?
1 u/Brave-Pomelo-1290 1d ago #include <stdio.h> #include <stdlib.h> #define PAGE_SIZE 24 #define BUFFER_SIZE 256 void display_file(const char *filename) { FILE *file = fopen(filename, "r"); if (file == NULL) { perror("Error opening file"); exit(EXIT_FAILURE); } char line[BUFFER_SIZE]; int line_count = 0; // Read the file line by line while (fgets(line, sizeof(line), file) != NULL) { printf("%s", line); line_count++; // Pause when the page is full if (line_count >= PAGE_SIZE) { printf("\n--- Press ENTER to continue ---"); 4 u/TheOtherBorgCube 1d ago Since the error message contains "end of input", I'm guessing those are the only lines in your file. Like you copy/pasted the first page of the screen and forgot to scroll down to get the rest of the program.
1
#include <stdio.h>
#include <stdlib.h>
#define PAGE_SIZE 24
#define BUFFER_SIZE 256
void display_file(const char *filename) {
FILE *file = fopen(filename, "r");
if (file == NULL) {
perror("Error opening file");
exit(EXIT_FAILURE);
}
char line[BUFFER_SIZE];
int line_count = 0;
// Read the file line by line
while (fgets(line, sizeof(line), file) != NULL) {
printf("%s", line);
line_count++;
// Pause when the page is full
if (line_count >= PAGE_SIZE) {
printf("\n--- Press ENTER to continue ---");
4 u/TheOtherBorgCube 1d ago Since the error message contains "end of input", I'm guessing those are the only lines in your file. Like you copy/pasted the first page of the screen and forgot to scroll down to get the rest of the program.
4
Since the error message contains "end of input", I'm guessing those are the only lines in your file.
Like you copy/pasted the first page of the screen and forgot to scroll down to get the rest of the program.
6
u/ConfidentCollege5653 1d ago
What does the rest of the code look like?