请各位高手帮我看看这道二级题
问题:为什么我的out.dat 文件会成这样#include <stdio.h>
#define M 3
#define N 20
void fun(char a[M][N], char *b)
{
int i,j; int t=0;
for (i=0; i<M; i++)
for(j=0; j<N; j++)
{
if(a[i][j]!='\0')
{
*b=a[i][j];
b++;
}
}
*b='\0';
}
main()
{ char w[M][N]={"AAAA","BBBBBBB","CC"}, a[100];
int i ;
printf("The string:\n");
for(i=0; i<M; i++)puts(w[i]);
printf("\n");
fun(w,a);
printf("The A string:\n");
printf("%s",a);printf("\n\n");
NONO();
}
NONO()
{/* 请在此函数内打开文件,输入测试数据,调用 fun 函数,输出数据,关闭文件。 */
FILE *rf, *wf ;
char w[M][N], a[100] ; int i ;
rf = fopen("D:\\Exam\\24010001\\in.dat","r") ;
wf = fopen("D:\\Exam\\24010001\\out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%s %s %s", w[0], w[1], w[2]) ;
fun(w, a) ;
fprintf(wf, "%s\n", a) ;
}
fclose(rf) ; fclose(wf) ;
}
这是我的答案
D:\\Exam\\24010001\\in.dat
AAAA BBBBBBB CC
SDKJF SDLKJFHSDLK KFDSJFDSD
CDSKFJHSD FDKSLJF FDSKLAFJSDLKF
FDLKSJF FDSL FSDLKFJSD
FSDKJLFHSD FDSKJFDS 32894FKDJS
FLKSDJF FDSLKJFDS FDSLKJFS
ODGPFBIDV 93204 FDSJUFL
LFKJSDLK FLKDSJFL FSDLKAJF
FSDLKJF 3294090432 FDLKSJFSD32DWED
FDSKJFDS 3232FSD FSDFSDFLFSDFSD
这是 in.dat文件
问题:为什么我的out.dat 文件会成这样??
D:\\Exam\\24010001\\out.dat
AAAA烫烫烫烫烫烫烫藼BBBBBB烫烫烫烫烫烫CC烫烫烫烫烫烫烫烫?
SDKJF烫烫烫烫烫烫烫SDLKJFHSDLK烫烫烫烫KFDSJFDSD烫烫烫烫烫
CDSKFJHSD烫烫烫烫烫FDKSLJFDLK烫烫烫烫FDSKLAFJSDLKF烫烫烫
FDLKSJFD烫烫烫烫烫FDSLJFDLK烫烫烫烫FSDLKFJSDLKF烫烫烫
FSDKJLFHSD烫烫烫烫蘁DSKJFDSLK烫烫烫烫32894FKDJSKF烫烫烫
FLKSDJFSD烫烫烫烫蘁DSLKJFDSK烫烫烫烫FDSLKJFSSKF烫烫烫
ODGPFBIDV烫烫烫烫?3204FDSK烫烫烫烫FDSJUFLSKF烫烫烫
LFKJSDLK烫烫烫烫蘁LKDSJFLK烫烫烫烫FSDLKAJFSKF烫烫烫
FSDLKJF烫烫烫烫?294090432烫烫烫烫FDLKSJFSD32DWED烫烫
FDSKJFDS烫烫烫烫?232FSD32烫烫烫烫FSDFSDFLFSDFSD烫烫
问题:为什么我的out.dat 文件会成这样??