Vector to csv

Im trying output the content of my vector to a csv file that already as 3 elements, however using this code outputs 4 empty elements following each of the 3 already established elements. It does not print out the vector that has been created earlier which has been confirmed to exist by cout.

Thank you in advanced for your help

Here's the code for outputing my file to csv:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
while(!inFile.eof())
    {
     // getline(inFile,record,',');          //Original 3 elements
        getline(inFile,Name,',');
        getline(inFile,ID,',');
   if( inFile.eof() ) break;
                     cout << " " <<;


        outFile << "Record: " << i++ << '\n'; //Original 3 elements
        outFile << "Name: " << Name << '\n';
        outFile << "ID: " << ID << '\n';
        outFile << "Email: " << Email << '\n';

        outFile << "--------------------" << '\n';
  

for (unsigned int v =0; v < sVec.size(); v++)                       // My vector
    {
        outFile << "\n\n Name: " << sVec.at(v).Name << '\n'
             << "\n ID: " << sVec.at(v).ID << '\n'
             << "\n Email: " << sVec.at(v).Email << '\n'
        << "Record Number: " << v << "\n" << '\n'
             <
can you post your whole code? including the part where you push back into your vector?
ios::app
http://www.cplusplus.com/reference/ios/ios_base/openmode/

I don't see you writting any commas to the file
your code doesn't compile, and I also want the file contents and the user input.
Hello yup2,

I have thought about your problem for awhile and the answer to your question is 42. https://www.youtube.com/watch?v=aboZctrHfK8

As ne555 said your code does not compile. I see no closing } for the while loop or the for loop and the "outFile" in the for loop appears to be incomplete.

You think the problem is in the code that you posted, but the problem could have started elsewhere and no one see that part. And without the input file one can only guess if you are reading it correctly and i do not think you are.

Do not expect people to look through your previous posts for answers. Your code today is likely much different than what you posted in the past.

Like hoogo and ne555 have said post your whole code and the input file to get a better answer.

Andy
Topic archived. No new replies allowed.