I have this code
while(1){
printf(\"hello world !\\n\");
fgetc(stdin);
}
when this runs and I enter a letter like this:
<
There are two characters: a and \n (newline). Your loop reads reads the a, then loops and prints "hello world !". It then sees \n and loops and prints "hello world !". When you type a+\n in the terminal, it's storing the two characters in the stdin buffer. fgetc(stdin); will read from the stdin buffer if there is a char available, otherwise it waits until a char is added to the buffer.
Since terminals are line-buffered (ie, do not send the content to the program until a newline is reached) you have a few options:
To turn off line buffering, look at http://c-faq.com/osdep/cbreak.html and http://www.flipcode.com/archives/_kbhit_for_Linux.shtml and http://ubuntuforums.org/showthread.php?t=225713 (although I have not tested any of the code here).