Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX 100
- unsigned char
- read_line(char *line, char *word);
- int main()
- {
- char line[MAX];
- if (read_line(line, "test_word") != 0)
- printf("found word\n");
- else
- printf("not found\n");
- return (0);
- }
- unsigned char
- read_line(char *line, char *word) {
- int c;
- unsigned char i = 0;
- while ((c = getchar()) != EOF && i < MAX - 1)
- line[i++] = c;
- line[i] = '\0';
- if (strstr(line, word) != 0)
- return (1);
- else
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment