python现有两个磁盘文件a和b_有两个磁盘文件A和B,各存放一行字母,今要求把这两个文件中的信息合并,输出到一个新文件C中。...
首先,在
.cpp
所在的文件夾下建立
A.txt
與
B.txt
。向其中輸入字母。
#include
#include
#include
int?main()
{
FILE?*a,*b,*c;
char?ch[100],outfile[10];
int?i=0,n;
void?paixu(char?a[100],int?n);
if((a=fopen("A.txt","r"))==NULL)
{
printf("Can't?open?the?file?'A.txt'");
exit(0);
}
if((b=fopen("B.txt","r"))==NULL)
{
printf("Can't?open?the?file?'B.txt'");
exit(0);
}
printf("
請輸入輸出的文件名:
");
scanf("%s",outfile);
if((c=fopen(outfile,"w"))==NULL)
{
printf("Can't?open?the?file?%s",outfile);
exit(0);
}
while(!feof(a))
ch[i++]=fgetc(a);
while(!feof(b))
ch[i++]=fgetc(b);
n=strlen(ch);
paixu(ch,n);
for(i=0;i
fputc(ch[i],c);
fclose(a);
fclose(b);
fclose(c);
return?0;
}
void?paixu(char?a[100],int?n)
{
int?i,j;
char?temp;
總結
以上是生活随笔為你收集整理的python现有两个磁盘文件a和b_有两个磁盘文件A和B,各存放一行字母,今要求把这两个文件中的信息合并,输出到一个新文件C中。...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 云南神龙峡锅圈崖降绳高度是多少米?
- 下一篇: 为什么这类耳鸣普遍呢?现在生活好,各种美