#include <stdio.h>
#include <string.h>
#define MAXLINE 1000
int getline(char *line, int max);
/* find: печать строк с образцом, заданным 1-м аргументом */
main(int argc, char *argv[])
{
    system("chcp 1251");
    char line[MAXLINE];
    int found = 0;
    if (argc != 2)
        printf("Используйте в find образец\n");
    else
        while (getline(line, MAXLINE) > 0)
            if (strstr(line, argv[1]) >= NULL) {
                printf ("%s", line);
                found++;
            }
    return found;
}

int getline(char *line, int max)
{
    int c, i;
    for (i = 0; i < max-1 && (c = getchar()) != EOF && c != '\n'; ++i)
        line[i] = c;
    if (c == '\n') {
        line[i] = c;
        ++i;
    }
    line[i] = '\0';
    return i;
}
