#include<stdio.h>
#include<STDLIB.H>
main()
{
FILE *f1,*f2,*f3;
char c[1];
int x;
f1=fopen("data.txt","r");
f2=fopen("odd.txt","w");
f3=fopen("even.txt","w");
while((c[0]=getc(f1)) != EOF)
{
x = atoi(c);
if(x%2==0)
putc(c[0],f3);
else
putc(c[0],f2);
}
fclose(f1);
fclose(f2);
fclose(f3);
}
#include<STDLIB.H>
main()
{
FILE *f1,*f2,*f3;
char c[1];
int x;
f1=fopen("data.txt","r");
f2=fopen("odd.txt","w");
f3=fopen("even.txt","w");
while((c[0]=getc(f1)) != EOF)
{
x = atoi(c);
if(x%2==0)
putc(c[0],f3);
else
putc(c[0],f2);
}
fclose(f1);
fclose(f2);
fclose(f3);
}
No comments:
Post a Comment