Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Write a program that will repeat k times each single occurrence of a vowel in the input file "sp.txt" to a new file "output.txt". The first line of the input file contains only the parameter k. The first line (containing the parameter k) should not to be written in the output file.
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main()
- {
- FILE *p=fopen("sp.txt" , "r");
- if(p==NULL)
- {
- printf("Nemoze da se otvori datotekata\n");
- return 0;
- }
- int samoglaski;
- int k;
- fscanf(p , "%d" ,&k);
- char c;
- FILE *out=fopen("out.txt" , "w");
- if(out==NULL)
- {
- printf("Nemoze da se otvori datotekata\n");
- return 0;
- }
- while(c=fgetc(p)!=EOF)
- {
- fprintf(out, "%c" , c);
- if(isalpha(c))
- {
- samoglaski=1;
- c=tolower(c);
- if(c=='a' && c=='e' && c=='i' && c=='o' && c=='u')
- while(samoglaski<k)
- {
- fprintf(out, "%c" , c);
- samoglaski++;
- }
- }
- }
- fclose(p);
- fclose(out);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment