为什么不对啊 大侠们教教我 关于文件
# include <stdio.h># include <stdlib.h>
FILE *write(char name)
{char ch;FILE *fp;
if((fp=fopen("name","w"))==NULL)
{printf("wrong");
exit(0);}
ch=getchar();
while(ch!='#')
{fputc(ch,fp);putchar(ch);
ch=getchar();}
fclose(fp);
return(fp);
}
void main()
{int i=0,j,t;char a[20];char ch1,ch2,ch;FILE *f;char name1='A';char name2='B';
do
{ch1=fgetc(write(name1));a[i]=ch1;i++;}while(ch1!=EOF);
do
{ch2=fgetc(write(name2));a[i]=ch2;i++;}while(ch2!=EOF);
a[i]='\0';
for(i=0;a[i]!='\0';i++)
for(j=i+1;a[j]!='\0';j++)
if(a[i]>=a[j])
{t=a[i];a[i]=a[j];a[j]=t;}
if((f=fopen("C","w"))==NULL)
{printf("wrong");
exit(0);}
i=0;
for(ch=a[i];a[i]!='\0';i++)
{fputc(ch,f);
putchar(ch);}
fclose(f);
}
把文件A和文件B存放的字母按顺序输出到一个文件C里 为什么我这个没有输出C的内容啊?是不是数组的赋值方式错了??大侠们教教我