ACP4_9

//BCA Support //www.bcasupport.xyz #include <stdio.h> void main(int argc,char *argv[]) { FILE *fp1,*fp2; char ch,word[20]=" ",temp[4]=" "; int a=0,b,count=0; clrscr(); if(argc!=3) { printf("Invalid command syntax"); getch(); exit(); } fp1=fopen(argv[1],"r"); fp2=fopen("word.txt","a"); strcpy(word,argv[2]); if(fp1==NULL) { printf("\nFile not found."); getch(); exit(); } if(fp2==NULL) { printf("\nError in creating output file 'word.txt'"); getch(); exit(); } while((strcmp("",word)!=0)) { while(!feof(fp1)) { for(b=0;b<3;b++) { ch=fgetc(fp1); if(ch==' '||ch=='\n') break; else temp[a++]=ch; } temp[3]='\0'; if(word[0]==temp[0] && word[1]==temp[1] && word[2]==temp[2]) count++; strcpy(temp," "); a=0; } fprintf(fp2,"%s\t- %d\n",word,count); printf("\nFrequncy of the word '%s' is saved " "in file 'word.txt'",word); printf("\n\nEnter another word : "); gets(word); count=0; rewind(fp1); clrscr(); } fcloseall(); getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.