fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define MAXLINE 1000
  4. int getline(char *line, int max);
  5. /* find: печать строк с образцом, заданным 1-м аргументом */
  6. main(int argc, char *argv[])
  7. {
  8. system("chcp 1251");
  9. char line[MAXLINE];
  10. int found = 0;
  11. if (argc != 2)
  12. printf("Используйте в find образец\n");
  13. else
  14. while (getline(line, MAXLINE) > 0)
  15. if (strstr(line, argv[1]) >= NULL) {
  16. printf ("%s", line);
  17. found++;
  18. }
  19. return found;
  20. }
  21.  
  22. int getline(char *line, int max)
  23. {
  24. int c, i;
  25. for (i = 0; i < max-1 && (c = getchar()) != EOF && c != '\n'; ++i)
  26. line[i] = c;
  27. if (c == '\n') {
  28. line[i] = c;
  29. ++i;
  30. }
  31. line[i] = '\0';
  32. return i;
  33. }
  34.  
Success #stdin #stdout #stderr 0s 9424KB
stdin
tosaka
stdout
Используйте в find образец
stderr
sh: 1: chcp: not found