Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char c,d;
- char s1[100],s2[100];
- int i;
- FILE *f1, *f2;
- printf("Vvedite imya faila vvoda: ");
- scanf("%s",s1);
- printf("Vvedite imya faila vivoda: ");
- scanf("%s",s2);
- printf("Vvedite iskomiy simvol: ");
- scanf("%s",&d);
- f1 = fopen(s1, "r");
- if( !f1 ) {
- printf("\nNe mogu otkryt fail vvoda\n\n");
- return;
- }
- f2 = fopen(s2, "w");
- if( !f2 ) {
- printf("\nNe mogu otkryt fail vivoda\n\n");
- return;
- }
- i=0;
- do {
- c=fgetc(f1);
- if(c == d) i=i+1;
- if(c == '\n' || c == EOF) {
- fprintf(f2,"%d\n",i);
- i=0;
- }
- } while(c!=EOF);
- fclose(f1);
- fclose(f2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement