It's your cin >> text.
When you enter a space the >> stops. Then you get to cin >> hrs >> mins >> secs and if the character after the space it not an int, you fail on cin >>hrs. That terminates the cin leaving garbage in your variables.
If your string has multiple words you need to use cin.getline().
Remember, the >> operator is for formatted input. That is, you know the type of data being entered before it is entered.
Lastly, you should check your >> operations for success by test the goodbit after the >>. And that means you probably shouldn't have multiple >> operations in one statement.
|