I'm having some trouble understanding the exactly what this function does. I keep thinking of it as a scanf. Does anyone have a link to a tutorial that would help me understand this a bit better?
I'm having some trouble understanding the exactly what this function does. I keep thinking of it as a scanf. Does anyone have a link to a tutorial that would help me understand this a bit better?
> I'm having some trouble understanding the exactly what this function does
Post a link to your online manual page, and indicate what is troubling you.
It only does one thing, and returns two possible things - a character, or EOF.
If you've understood anything at all of scanf (which is a far more complicated function), then getchar() should be a breeze.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
The name alone tells you exactly what it does. It gets a char.
The only slightly confusing part of it is that it returns an int instead of a char, but that's just because EOF can't fit in a char.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
it getchar getcharacter from your keyboard to exit :P
It retreives a character from the standard input stream.