C语言一次性读取多个CSV表格



#include 
#include
#include 
using namespace std;


//=================================================================================
//path: the path of CSV file
//arr2: the data of CSV saved in arr2
//the memory of arr2 is not malloc()ed in my_ReadSingleCSV(),
//thus,the function that call my_ReadSingleCSV() must malloc() memory for arr2
//ROWS: total rows of CSV sheets
//COLS: total columns of CSV sheets
void my_ReadSingleCSV(char *path, double **arr2, int ROWS, int COLS)
{
    FILE *fp = NULL;
    fp = fopen(path, "at+");
    if ( NULL == fp )
    {
            cout << "Failed to open " << path << endl;
    }


    char d;
    int ret=1;
    int i = 0;

    while ( ret != EOF && i < ROWS )
    {
    	for(int j=0; j



运行结果:


DatasAllCSV[0]=: 
1.000000  2.000000  
2.000000  4.000000  

DatasAllCSV[1]=: 
2.000000  4.000000  
4.000000  8.000000  

DatasAllCSV[2]=: 
3.000000  6.000000  
6.000000  12.000000  

DatasAllCSV[3]=: 
4.000000  8.000000  
8.000000  16.000000  



C语言一次性读取多个CSV表格_第1张图片



            









你可能感兴趣的:(C++,基础知识)