fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void) {
  5. # define fp stdin
  6. # define terminal_cmd "terminate\n"
  7. # define LINE_MAX sizeof terminal_cmd
  8. /* NOTE: The next source lines of code are taken from POSIX manpages:
  9.   <http://p...content-available-to-author-only...p.org/onlinepubs/009696699/functions/fgets.html> */
  10. char line[LINE_MAX];
  11. while (fgets(line, LINE_MAX, fp) != NULL) {
  12. printf("{%s}", line); // print the "line" of input with brackets
  13. if (!strcmp(line, terminal_cmd))
  14. return 0;
  15.  
  16. int integer;
  17. if (sscanf(line, "%d", &integer) != 1)
  18. continue;
  19.  
  20. printf("%d\n", integer * integer);
  21. }
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 9424KB
stdin
buggggggy terminate
42
stdout
{buggggggy }{terminate
}