hi I would like to ask how I would modify this code for the question: (It only accepts one input then prints it out. I want it to keep going until I hit enter (\n) twice.
#include <stdio.h>
#define MAXLENGTH 1000
int main(void) {
char string[MAXLENGTH];
fgets(string, MAXLENGTH, stdin );
printf("%s\n", string);
return 0;
}
I'm confused at the fgets(string, MAXLENGTH, stdin ); line, what does stdin mean/do?
EDIT: Chris, I've tried your way:
#include <stdio.h>
#define MAXLENGTH 1000
int main(void) {
char string[MAXLENGTH];
do {
if (!fgets(string, MAXLENGTH, stdin ))
break;
printf("%s", string);
}
} while (string[0] != '\n');
return 0;
}
It prints after i hit enter but i want to type the whole list first then allow it to print the list after I press enter twice.