I'm not positive if this is even the correct logic for this. Basically, I'm just trying to use the enter key as part of the condition in my while loop.
I've tried all sorts of comparisons, but none of them function the way I'm looking for. When I hit enter, it either creates an empty line, and does so each time its pressed, or it'll return the output, but still won't let me break the loop with pushing enter only.
cout << "Enter a short of just enter to move to the next data type: " ;
cin >> shortNum;
while(shortNum != '\n')
{
cout << "The absolute value of " << shortNum << " is: " << absoluteValues(shortNum) ;
cout << "\nEnter a short or just enter to move to the next data type: ";
cin >> shortNum ;
}
Aucun commentaire:
Enregistrer un commentaire