code for accessing File in C

/*This code will create one file with name Source.txt then copy only consonants into another file named as Target.txt*/

#include<stdio.h>
void main() {
FILE *fp,*fp1;
char ch;
fp=fopen("Source.txt","w+");
while((ch=getche())!=13)
{
fputc(ch,fp);
}
fclose(fp);
fp=fopen("Source.txt","r");
fp1=fopen("target.txt","w+");
while((ch=fgetc(fp))!=EOF)
{
if(ch!='a' && ch!='e' && ch!='i' && ch!='o' && ch!='u')
fputc(ch,fp1);
}
fclose(fp1);
}

Comments

Popular posts from this blog

JAVA program to add two distance

Print Pattern using C