| strings/string-input-gets.c - Et program der indlæser en line af tekst med gets - usikkert. | Lektion 10 - slide 48 : 51 Program 1 |
// Source file: string-input-gets.c
#include <stdio.h>
#include <string.h>
#define LIMIT 20
int main(void) {
char input[LIMIT];
do {
printf("Enter a string: ");
gets(input); // Dangerous if the input entered
// is longer than LIMIT
printf("You entered \"%s\"\n", input);
} while (strcmp(input, "exit"));
return 0;
}