0

so I have these two csv files I need to read, they each have several columns of text separated by spaces. how do I split these rows into tokens without using vectors or arrays? I'm doing this in c++ and can't find any help.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

   int main() {
      string line;
       ifstream myfile ("elect12.csv");
       if (myfile.is_open ())
        {
         cout << endl << "popular results " << endl;
         while (getline (myfile, line))
         {
          cout << line << endl;
         }
        myfile.close();
       }
       else cout << "unable to open";

      string line1;
       ifstream myfile1 ("ev10.csv");
       if (myfile1.is_open ())
        {
         cout << endl << "electoral votes per state" << endl;
         while (getline (myfile1, line1))
         {
          cout << line1 << endl;
         }
        myfile1.close();
       }
       else cout << "unable to open";

return 0;
}

the image included is what the output looks like right now

0 Answers0