title: breaking loop with keypress in linux c
body: <p>I need to write a program in C language which will be doing something like this:
  For example, when I will press "a", terminal will be writing that typed character in the unending loop like this:  aaaaaaaaaaaaaaaa...until another key, for example "b" will be pressed. Final output should look like this: aaaaaaaaabbbbbbq (q should terminate the program).
  My code here:</p>
  
  <pre><code>int main(int argc, char** argv) {
  
      int c;
      static struct termios staryTermios, novyTermios;
  
  
      tcgetattr(STDIN_FILENO, &amp;staryTermios);
  
      novyTermios = staryTermios;
      novyTermios.c_lflag &amp;= ~(ICANON);
      tcsetattr(STDIN_FILENO, TCSANOW, &amp;novyTermios);
      while ((c = getchar()) != 'q') {
          putchar(c);
      }
  
      tcsetattr( STDIN_FILENO, TCSANOW, &amp;staryTermios);
  
      return 0;
  }
  </code></pre>
  
  <p>this version writes the typed characters only once and then it waits for another keypress</p>