将文件中的内容用fsanf读入字符串数组 有错 字符串数组是两维的
#include "stdio.h"#include "string.h"
int main()
{
FILE *fp;
char arr_in[][10]={"London","Paris","Bon","Rome","Tokoyo","Detroit","Moscow",
"Jerualern","Bombery","Beijing"};//10个字符串
char arr_out[20][20];
int i;
fp=fopen("in&out.txt","w");//没有文件就创建
for(i=0;i<=9;i++)
fprintf(fp,"%10s",arr_in[i]);//注意格式
rewind(fp);
printf("由文件输出屏幕\n");
i=0;
while(!feof(fp))
{
fscanf(fp,"%10s",arr_out[i++]);
}
fclose(fp);
for(i=0;i<=9;i++)
printf("%s",arr_out[i]);
}
----------------解决方案--------------------------------------------------------
fp=fopen("in&out.txt","wt+");//设置成可读写
----------------解决方案--------------------------------------------------------
怎么把这点疏忽了 谢了 怪不得
----------------解决方案--------------------------------------------------------