/*********************************************************************
 *event-loop.c
 *
 *Basic event loop for cs128 lab.
 *
 *Josh McCoy
 ********************************************************************/

#include <iostream>
#include <string>
#include <unistd.h>

using namespace std;

//number of microseconds to sleep
const unsigned int SLEEP_TIME = 100000;

int main(int argc, char * argv)
{
	bool exit = false;
	string input = "";

	while(!exit){
		input = "";
		if(cin.peek()){
			cout << cin.peek() << endl;
			cin >> input;
			cout << input;
		}else{
			cout << cin.peek() << endl;
			cout << "waiting for input" << endl;
		}

		if(input == "q"){
			cout << "ready to exit" << endl;
			exit = true;
		}
		
		usleep(SLEEP_TIME);
	}
 	return 0;
}
