问题百思不解,希望有人可以帮忙
请教一下这个程序-----没有显示错误,但是执行会出现这个情况
程序如下:
程序代码:
#include<stdio.h> void main() { FILE *fp; int i,j,n,ni; char c[160],t,ch; if((fp=fopen("A","r"))==NULL) { printf("file A cannot be opened\n"); } printf("\n A contents are :\n"); for(i=0;(ch=fgetc(fp))!=EOF;i++) { c[i]=ch; putchar(c[i]); } fclose(fp); ni=i; if((fp=fopen("B","r"))==NULL) { printf("file B cannot be opened\n"); return ;} printf("\n B content are:\n"); for(i=0;(ch=fgetc(fp))!=EOF;i++) { c[i]=ch; putchar(c[i]); } fclose(fp); n=i; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(c[j]>c[i]) { t=c[i];c[i]=c[j];c[j]=t;} printf("\n C file is:\n"); fp=fopen("C","w"); for(i=0;i<n;i++) { putc(c[i],fp); putchar(c[i]); } fclose(fp); }