Advertisement
cd62131

AcceptLine

Aug 10th, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. static char *end_line(char *line) {
  5.   static const char *end ="end";
  6.   return strstr(line, end);
  7. }
  8. int main(void) {
  9.   char line[BUFSIZ];
  10.   const char *prompt = "> ";
  11.   printf("%s", prompt);
  12.   while (fgets(line, BUFSIZ, stdin)) {
  13.     if (end_line(line)) break;
  14.     printf("%s", line);
  15.     printf("%s", prompt);
  16.   }
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement