Showing
1 changed file
with
7 additions
and
1 deletions
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | +#include <string.h> | ||
| 2 | 3 | ||
| 3 | int main(void) { | 4 | int main(void) { |
| 4 | printf("Input a string\n"); | 5 | printf("Input a string\n"); |
| 6 | + printf("Will exit on input \"exit\"\n"); | ||
| 5 | 7 | ||
| 6 | while (1) { | 8 | while (1) { |
| 7 | char str[50]; | 9 | char str[50]; |
| 8 | scanf("%s", str); | 10 | scanf("%s", str); |
| 9 | - printf("%s\n", str); | 11 | + if (strcmp(str, "exit") == 0) { |
| 12 | + break; | ||
| 13 | + } else { | ||
| 14 | + printf("%s\n", str); | ||
| 15 | + } | ||
| 10 | } | 16 | } |
| 11 | 17 | ||
| 12 | return 0; | 18 | return 0; | ... | ... |
-
Please register or login to post a comment