Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) I open the input file
- 2) I read it
- 3) Store an 2D array
- 4) split into tokens
- 5) firslt strtok for "n" and store it
- 6) secondly strtok for ":" ignore it
- 7)and then strtok for "," and store it
- 8) I want to search a word for every single line (which I stored it step 5)
- 9) For searching I use strstr but I can't do it.
- int main (){
- FILE *fp;
- fp=fopen("C:\input.txt","r");
- char *name[10][10];
- char row[100];
- char *token,*tkn,*tk;
- int h=0, f=0, l=0;
- for(h=0;h<9;h++){
- for(f=0;f<9;f++)
- name[h][f]=NULL;
- }
- while(fgets(row,sizeof(row),fp)){
- token=strtok(row,"n");
- name[l][0] = strdup(token);
- //printf("%s",name[l][0]);
- tkn=strtok(token,":");
- tk=strtok(tkn,",");
- isim[l][1]=strdup(tk);
- if(strstr(name[l][1],name[l+1][0])==0 || strstr(name[l][1],name[l+2][0])==0 || strstr(name[l][1],name[l+3][0])==0){
- }
- l++;
- }
- fclose(fp);
- }
- George :Math1,History2,Math2
- ELizabeth :Math2,Germany1,spanish1
- Adam :Germany1,History2,Math1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement