Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void DoAction()
- {
- printf("1 ");
- }
- void main()
- {
- FILE *fi = fopen("blablabla.txt", "r");
- if(fi == NULL)
- return;
- char String[200];
- char *S;
- while(!feof(fi))
- {
- fgets(String, sizeof(String), fi);
- /*for(int i=0; i < sizeof(String); i++)
- {
- if(String[i] == 'd' && String[i+1] == 'o' && String[i+2] == ' ')
- DoAction();
- }*/
- S=strstr(String, "do ");
- while(S != NULL)
- {
- DoAction();
- S=strstr(S+3, "do "); // 3 é o tamanho da palavra do mais o espaço strstr procura a string "do " dentro da string S
- }
- }
- fclose(fi);
- }
Advertisement
Add Comment
Please, Sign In to add comment