I need to read one line after another of the data from .csv file. Line length may vary so I want to use the dynamic structure but I don't know how. There are only floats, no mixed types. I can use only standard libraries.
#include<iostream>
#include<fstream>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
ifstream obraz;
obraz.open("POP_OCT.csv", ios::binary);
if(!obraz)
cerr<<"couldn't open file"<<endl;
float length; //actually this one comes from the file
while( !obraz.eof() ) // read lines
{
//read data from the verse to line[]
for(int i=0; i<500; i++)
{
obraz>>line[i];
obraz.seekg(+1, ios_base::cur);
}
obraz.close()
return 0;
}
This is how I do it with normal table but it's size is defined as 500. If I read in another file length may be different so how to use dynamic table here?