How to read and store multiple input divided by whitespace to the same variable? Is it possible?

This is what I have so far..


#include "Menu.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

class Menu
{
private:
ifstream fileName;
string firstName;
string lastName;
int id;
int scores;
string inputFile;
string line;
string assignInfo = "Project 1 by Courtney J. Walker and Joseph Lee.";

public:
void input();
};

void Menu::input()
{
cout << assignInfo << endl;
cout << "Enter File Name (Enter 'quit' to exit): ";
cin >> inputFile;

if (inputFile != "quit")
{
cout << "Your filename is " << inputFile << endl;
try
{
fileName.open(inputFile.data(), ios::in);
}
catch (...)
{
cout << "File open error" << endl;
}

while (! fileName.eof() )
{
getline(fileName, line, ' ');
cout << "__________ " << line << endl;
}

}

cout << "Program exiting.";
fileName.close();

}

int main()
{

}
Topic archived. No new replies allowed.