Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main(int argc,char *argv[])
- {
- FILE *fp,*fp1;
- int i,len,j,wcount=0,ncount=0,m,k;
- char s[1000];
- fp1=fopen("newtext.txt","w");
- for(i=1; i<argc; i++)
- {
- fp=fopen(argv[i],"r");
- while(fgets(s,50,fp)!=NULL)
- {
- len=strlen(s);
- m=0;
- for(j=0;j<=len;j++)
- {
- if(s[j]==' '||s[j]=='\n'||s[j]=='0/'||s[j]==EOF)
- {
- if(s[j-1]>='A'&&s[j-1]<='Z'||s[j-1]>='a'&&s[j-1]<='z')
- {
- wcount++;
- printf("word #%d : ",wcount);
- fprintf(fp1,"word #%d : ",wcount);
- for(k=m;k<j;k++)
- {
- printf("%c",s[k]);
- fprintf(fp1,"%c",s[k]);
- }
- printf("\n");
- fprintf(fp1,"\n");
- }
- else if(s[j-1]>='0'&&s[j-1]<='9')
- {
- ncount++;
- printf("number #%d : ",ncount);
- fprintf(fp1,"number #%d : ",ncount);
- for(k=m;k<j;k++)
- {
- printf("%c",s[k]);
- fprintf(fp1,"%c",s[k]);
- }
- printf("\n");
- fprintf(fp1,"\n");
- }
- m=j+1;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment