file program issue
Apr 15, 2014 at 5:24pm UTC
Write your question here.
1 2 3
B17 -> B19 [label="{10}" ];
B17 -> B21 [label="{4}" ];
B18 -> B19 [label="{4}" ];
Can any one help with the pointer solution to check in file for this -> symbol and one it finds the symbol it should move behind 4 characters and store the string
B17 in an array and then move 4 characters ahead and similarly save B21 likewise for each line do as above..
Apr 15, 2014 at 5:26pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int wc(char * file_path, char * word){
FILE *fp;
int count = 0;
int ch, len;
if (NULL==(fp=fopen(file_path, "r" )))
return -1;
len = strlen(word);
for (;;){
int i;
if (EOF==(ch=fgetc(fp))) break ;
if ((char )ch != *word) continue ;
for (i=1;i<len;++i){
if (EOF==(ch = fgetc(fp))) goto end;
if ((char )ch != word[i]){
fseek(fp, 1-i, SEEK_CUR);
goto next;
}
}
++count;
next: ;
}
end:
fclose(fp);
return count;
}
int main(){//testestest : count 2
char key[] = "->" ; // the string I am searching for
int wordcount = 0;
wordcount = wc("test.txt" , key);
printf("%d \n" ,wordcount);
return 0;
}
i m able to find the symbol -> but not getting idea how to proceed ahead..
Help..
Topic archived. No new replies allowed.