I'm reading in user input via
string word;
while(cin >> myWord)
//put myWord in array
but for the sake of sorting I want "This" and "this" to be the same. For my sort algorithm I'm using the default < and > values for string, so This != this, and for my purposes I need it to == so I want to just immediately make everything lowercase while it's read in. From the tolower I see I would need to make a for
loop to iterate through word and make it lowercase, so I'd need to do this inside of the while loop before putting the word into the array. But I'm wondering if there's any trick I can do to make put the word from cin into myWord
already lower case (or make "myWord" lower case right after being read in) in one line, along the lines of cin >> myWord.lower
is what I'm talking about