/*假设你的数据文件是d:\ttt.txt\x0d\x0a 用循环把数字读到数组a里面顺便显示出来 */\x0d\x0a#include \x0d\x0aint main()\x0d\x0a{\x0d\x0adouble a[100];\x0d\x0aint i=0;\x0d\x0aFILE* fp;\x0d\x0aif((fp=fopen("d:\\ttt.txt","r"))==0)\x0d\x0a{...
int v[100];//开一个足够大的数组。int i = 0, j;FILE *fp;//文件指针 fp = fopen("in.txt", "r");//以文本方式打开文件。if(fp == NULL) //打开文件出错。return -1;while(fscanf(fp, "%d", &v[i]) != EOF) //读取数据到数组,直到文件结尾(返回EOF)i++;fclose(fp...
//若使用一维数组使用以下程序 #include <stdio.h> main() { char s1[20] = {0}; char s2[20] = {0}; char s3[20] = {0}; int i=0; FILE *fp; fp = fopen("1.txt","r"); fscanf(fp,"%s",s1); fscanf(fp,"%s",s2); fscanf(fp,"%s",s3); printf("%s\n%s\n%s\n",s1,...