Your infinite loop is caused by your for condition. I'm sure you are expecting cin to prompt you for more input but your program shoots off into never never land. Your problem is bad data you are entering in. cin is interpreting the data you enter in the following way:
Data: 13 shoot if they shoot first
Loop1:
time_of_day = 13
command = shoot
Loop2:
time_of_day = if (error; all bets are off from here)
command = shoot
Loop3:
...
Your program works if you enter data like this:
data: 13 shoot 14 dude 15 kill 16 hello
If you want to enter a string after the number it is a bit tricker. You will have to use get or getline. I think they are cin members.
Here is a way to check for bad data:
Code:
#include <iostream>
main( )
{
char command[40];
int time_of_day;
const bool ever = 1;
do
{
cin >> time_of_day >> command;
if ( cin.fail() )
cout << "Get lost you idiot!" << endl;
else
cout << "Command was " << command
<< " at time "
<< time_of_day << endl
;
} while ( !cin.fail() && !cin.eof() );
}