#include<stdio.h>
int main()
{
FILE *p1,*p2,*p3;
char f1[20], f2[20],f[30];
char ch;
int count1=0,count2=0,count3=0;
printf("Enter File name which has to be copied: ");
gets(f1);
p1=fopen(f1,"r");
if(p1==NULL)
{
printf("\nUnable to open %s",f1);
return 1;
}
printf("\nEnter Name of File in which you want to copy Data : ");
gets(f2);
p2=fopen(f2,"w");
if(p2==NULL)
{
printf("Cannot open %s",f2);
return 1;
}
rewind(p1);
while((ch=fgetc(p1))!=EOF)
{
if(ch=='A' || ch=='a')
{
count1++;
}
if(ch=='b' || ch=='B')
{
count2++;
}
if(ch==' ')
{
count3++;
}
fputc(ch,p2);
}
printf("a = %d ,b = %d , space = %d",count1,count2,count3);
printf("\n\nData of File 1 Has been copied to File 2\n\n\n");
fclose(p1);
fclose(p2);
return 0;
}
int main()
{
FILE *p1,*p2,*p3;
char f1[20], f2[20],f[30];
char ch;
int count1=0,count2=0,count3=0;
printf("Enter File name which has to be copied: ");
gets(f1);
p1=fopen(f1,"r");
if(p1==NULL)
{
printf("\nUnable to open %s",f1);
return 1;
}
printf("\nEnter Name of File in which you want to copy Data : ");
gets(f2);
p2=fopen(f2,"w");
if(p2==NULL)
{
printf("Cannot open %s",f2);
return 1;
}
rewind(p1);
while((ch=fgetc(p1))!=EOF)
{
if(ch=='A' || ch=='a')
{
count1++;
}
if(ch=='b' || ch=='B')
{
count2++;
}
if(ch==' ')
{
count3++;
}
fputc(ch,p2);
}
printf("a = %d ,b = %d , space = %d",count1,count2,count3);
printf("\n\nData of File 1 Has been copied to File 2\n\n\n");
fclose(p1);
fclose(p2);
return 0;
}
No comments:
Post a Comment