#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *p1;
FILE *p2;
FILE *p3;
char ch1,ch2,ch3;
if((p3=fopen("3.txt","w+"))==NULL)
{
perror("open error\n");
exit(1);
}
if((p1=fopen("1.txt","r+"))==NULL)
{
perror("open error\n");
exit(1);
}
if((p2=fopen("2.txt","r+"))==NULL)
{
perror("open error\n");
exit(1);
}
while((ch1=fgetc(p1))!=EOF&&(ch2=fgetc(p2))!=EOF)
{
if((ch1<'0'||ch1>'9')&&(ch2<'0'||ch2>'9'))
{
fputc(ch1,p3);
}
else
{
ch3=ch1-'0'+ch2-'0'+'0';
fputc(ch3,p3);
}
}
fclose(p1);
fclose(p2);
fclose(p3);
return 0;
}
#include <stdlib.h>
int main()
{
FILE *p1;
FILE *p2;
FILE *p3;
char ch1,ch2,ch3;
if((p3=fopen("3.txt","w+"))==NULL)
{
perror("open error\n");
exit(1);
}
if((p1=fopen("1.txt","r+"))==NULL)
{
perror("open error\n");
exit(1);
}
if((p2=fopen("2.txt","r+"))==NULL)
{
perror("open error\n");
exit(1);
}
while((ch1=fgetc(p1))!=EOF&&(ch2=fgetc(p2))!=EOF)
{
if((ch1<'0'||ch1>'9')&&(ch2<'0'||ch2>'9'))
{
fputc(ch1,p3);
}
else
{
ch3=ch1-'0'+ch2-'0'+'0';
fputc(ch3,p3);
}
}
fclose(p1);
fclose(p2);
fclose(p3);
return 0;
}