fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4.  
  5. int searchnext(FILE*f, const char*s)
  6. {
  7. int c;
  8. fpos_t p; fgetpos(f, &p);
  9. c = fgetc(f); if (c == EOF) return 0;
  10. if (tolower((unsigned char)c) == tolower((unsigned char)*s))
  11. {
  12. if (!*++s) return 1;
  13. else
  14. return searchnext(f, s);
  15. }
  16. fsetpos(f, &p);
  17. return 0;
  18. }
  19.  
  20. int searchfor(FILE*f, const char*s)
  21. {
  22. int c;
  23. while ((c = fgetc(f)) != EOF)
  24. {
  25. if (tolower((unsigned char)c) == tolower((unsigned char)*s) && searchnext(f, s + 1)) return 1;
  26. }
  27. return 0;
  28. }
  29.  
  30. int main(int argc,char**argv)
  31. {
  32. return searchfor(stdin, argv[1]);
  33. }
  34.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
Standard output is empty