c++怎么读取csv文件并赋值到数组中
c++编程读取csv文件,621行,1000列的数据存进二维数组里面,数据都是double#include<iostream>
#include<stdio.h>
#include <cstdlib>
using namespace std;
double x;
int main()
{
FILE *fp;
int row = 62, col = 1000;
int i, j;
fp = fopen("C:/Users/Administrator/Desktop/data/data/pca_dataset1.csv", "r");
for (j = 0;j<row;j++)
for (i = 0;i<col;i++)
fscanf_s(fp, "%lf", &x);
int m,n;
int count = 0;
for (m = 0;m < row;m++)
for (n = 0;n < col;n++)
{
cout.setf(ios::fixed,ios_base::floatfield);
cout << x;
count++;
}
cout << endl;
cout << count;
fclose(fp);
//cout << x;
system("pause");
return 0;
} 我这段代码,运行读出的数据怎么都是0
页:
[1]