![Quote](https://cboard.cprogramming.com/images/misc/quote_icon.png)
Originally Posted by
grumpy
The logic of your code escapes me - probably because you've been adding code by guesswork and relying on prayer to get it working.
An obvious problem, since you have said that your program is supposed to be writing to output.txt, is that output.txt is only ever opened for reading, and data is only read from it.
i changed a little but again its doesnt work. its compiles correctly but doesnt print anything.
Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
#define MAX 100
int check_vowel ( char c) {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
void wtf() {
FILE *f = fopen("output.txt", "w");
char c;
while((c = getchar()) != EOF) {
fputc(c, f);
}
fclose(f);
}
void rff() {
FILE *f = fopen("sp.txt", "r");
char c;
while((c = fgetc(f)) != EOF) {
putchar(c);
}
fclose(f);
}
int main() {
wtf();
FILE *f = fopen("sp.txt", "r");
FILE *f2= fopen("output.txt","w");
char c;
int k, i;
char line[100];
fgets(line,100,f);
scanf("%d",&k);
while((c = fgetc(f)) != EOF) {
if(isalpha(c)){
if(check_vowel(tolower(c))) {
for (i=0; i<=k; i++)
fprintf(f2,"%c",c);
}
else
fprintf(f2,"%c",c);
}
else
fprintf(f2,"%c",c);
}
fclose(f);
fclose(f2);
rff();
return 0;
}