title: C Programming, how to run a for loop while waiting for user input
body: <p>for my coding assignment, I am having trouble. </p>
  
  <p>The gist of what I want to achieve is to run a program that alternates a variable char OUTPUT between  'A' and 'B' every 1 minute. So the first minute, OUTPUT should be A. The second minute, it'll be B. So on and so forth. </p>
  
  <p>However, if a user inputs the character P, OUTPUT will be P for a minute before returning to the A/B cycle. </p>
  
  <p>I haven't exactly gotten code down yet, because none of my attempts have worked. I've tried using while and for loops. But every time I use scanf or getchar(), the program stops indefinitely to wait for the user input.</p>
  
  <pre><code>void timer(){
  int t, d, change;
  char p;
  
  for(t = 1; t &lt;= 30000; t++)
  for(d = 1; d &lt;= 30000; d++){
      if(t == 30000){
          change = 1;
      }
      else if(p == 'p'){
          change = 0;
      }  
      else{
          p = getchar();
      }
  </code></pre>
  
  <p>is sorta what I have right now. It's a rather incomplete function, but change is supposed to return 1 or 0 and in the main function, if it's 1, the OUTPUT will change to A/B.</p>
  
  <p>I've also done some research and most people recommend multithreading, but we haven't learned that in class, so we can't use that for the program. I also don't have access to sleep() or delay(). Basically I'm restricted to the standard c library.</p>