I am trying to read in from a text file a poem that contains commas, spaces, periods, and newline character. I am trying to use getline to read in each separate word. I do not want to read in any of the commas, spaces, periods, or newline character. As I read in each word I am capitalizing each letter then calling my insert function to insert each word into a binary search tree as a separate node. I do not know the best way to separate each word. I have been able to separate each word by spaces but the commas, periods, and newline characters keep being read in.
Here is my text file:
Roses are red, Violets are blue, Data Structures is the best, You and I both know it is true.
The code I am using is this:
string inputFile;
    cout << "What is the name of the text file?";
    cin >> inputFile;
    ifstream fin;
    fin.open(inputFile);
    //Input once
    string input;
    getline(fin, input, ' ');
    for (int i = 0; i < input.length(); i++)
    {
        input[i] = toupper(input[i]);
    }
    //check for duplicates
    if (tree.Find(input, tree.Current, tree.Parent) == true)
    {
        tree.Insert(input);
        countNodes++;
        countHeight = tree.Height(tree.Root);
    }
Basically I am using the getline(fin,input, ' ') to read in my input.
 
     
     
     
    