Showing
1 changed file
with
6 additions
and
0 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); |
| 11 | + if (strcmp(str, "exit") == 0) { | ||
| 12 | + break; | ||
| 13 | + } else { | ||
| 9 | printf("%s\n", str); | 14 | printf("%s\n", str); |
| 10 | } | 15 | } |
| 16 | + } | ||
| 11 | 17 | ||
| 12 | return 0; | 18 | return 0; |
| 13 | } | 19 | } | ... | ... |
-
Please register or login to post a comment