How to make a routine in C keep running and not stop until I execute a command?

2

Good Night, I would like to do a routine in C type like this: Let's say I have a loop that prints the letter 'a' and while I do not type anything it continues printing, however by the time I hit 'c' for example, it starts printing the letter 'c' and stays printing while I did not type anything. That's more or less what I'd like but I can not reproduce that. Thanks!

    
asked by anonymous 01.04.2017 / 00:20

1 answer

1

You can use kbhit :

do
{
  puts("c");
} while(!kbhit());

The only problem is that it does not work on all compilers.

  

Use examples in other compilers: examples

    
01.04.2017 / 01:00