主题:如何从外部读取文件数据存入数组中
各位高手门:
#include <fstream>
#include <cstdlib>
#include <iostream>
#define MAX_LENGTH 100
using namespace std;
double p[10];
int main(void)
{
char line[MAX_LENGTH];
ifstream fin("D:\\My Documents\\shuju.txt");
while( fin.getline(line, MAX_LENGTH) )
{
cout << "read line: " << line << endl;
}
system("pause");
return 0;
}
这是我的程序,但我不知怎么存入到数组p[10]里头去,
从那里把数据写入数组,谢了.
#include <fstream>
#include <cstdlib>
#include <iostream>
#define MAX_LENGTH 100
using namespace std;
double p[10];
int main(void)
{
char line[MAX_LENGTH];
ifstream fin("D:\\My Documents\\shuju.txt");
while( fin.getline(line, MAX_LENGTH) )
{
cout << "read line: " << line << endl;
}
system("pause");
return 0;
}
这是我的程序,但我不知怎么存入到数组p[10]里头去,
从那里把数据写入数组,谢了.