That's an evil loop. NEVER do it like that abstractly!! it occupies your processor fully.
You may use sleep functions, they are available in many C libraries. Add a sleep function to that loop, if your program sleeps 1 second before every check, you'd be doing your processor a favour. If you have a 3 GHz processor, that empty loop is gonna execute 3 Billion times (since it's empty)!!!! So you're really doing your processor a favour with that sleep approach.
And to stop that loop, use a system signal, like the break signal with Ctrl+C.