I am trying to write some data to a CSV format, but I do have a problem. Sime I have a lot of data rows, it looks like some data may not fall into the right column. To get started, I used the stream class to create the file like

PHP Code:
ofstream myFile("data.csv");
//create the columns
myFile<<"column1,"<<"column2,"<<"column3,"<<"column4,"<<endl
I do have more colmns then that, but that is not an issue. It looks like I have to put the colmns in the std vector format, then read the colmns and append specific data to the right column and the right row. It is not straight forward, since I have different sections in the program where I have to read data from. I mean not a single function, but different functions.

At the end, I would like to have something like that in the file

column 1 column 2 colunn 3
====== ====== ======
data 1 data 2 data 3
data 4 data 5 data 6

I am not familiar with std vector, how can I use std vector to store the columns and happend specific data to the right column and write it to the file? This is basically what I need