so what im trying to do is read one line words at the time and seperate the words too.

so I read line 1:
add cars

line 2:
subtract cars
my progarm should know they are in the same line and store the words separete
and I will do something with word 2 depending on what word one was.

so I will have a function that adds the word cars to an array in line 1

here is my code that reads a datafile
Code:
#include <iostream>
#include <string>
#include <sstream>  

using namespace std;

int main() {

    string word;
    ifstream input;
    
    input.open("test.dat",ios::in);

    while (input >> word) {

      cout << word << endl;}
    input.close();



  return 0;
}

i want it to do this read one line at the time and separate the words
Code:
#include <iostream>
#include <string>
#include <sstream>  // for istringstream

using namespace std;

int main() {
  istringstream strLine;
  string line, word;
  int currentLine=0;

  while (getline(cin,line)) {
    ++currentLine;
    
    // clear the strstream and copy the entered line to it
    strLine.clear();
    strLine.str(line);

    // now get each word-sequence from the strLine stream
    while (strLine >> word)
      cout << currentLine << ": " << word << endl;
    }

  return 0;
}