Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int count=0;
- int j = 20;
- int i = 0;
- char arr[20];
- FILE *source;
- source = fopen("D:file1.txt", "r"); //open source
- while (fgets(arr, 20, source) != NULL)
- // printf("%c %c %c %c %c %c... and so on\n", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]); //TEST
- for( i=0 ; i<(j-4) ; i++ ){
- if( (arr[i]=='t') && (arr[i+1]=='e') && (arr[i+2]=='k') && (arr[i+3]=='s') && (arr[i+4]=='t') ) {
- // printf("if runs"); //TEST
- count++;
- }
- }
- printf("I have found such phrase %d times.\n", count);
- fclose(source);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement