Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // apple xcode
- // paulogp
- /* getchar problem */
- /* Despite what it says in the brochure, getchar() does not read a
- single char acter from the keyboard. That's what the getchar()
- function returns, but it's not what the function does.
- Internally, getchar() reads what's called standard input. It grabs
- the first character you type and stores it, but afterward it sits
- and waits for you to type something that signals "the end." */
- #include <stdio.h>
- int main (int argc, const char * argv[])
- {
- char the_char_a, the_char_b;
- printf("caracter a: ");
- the_char_a = getchar();
- fpurge(stdin); // fflush(stdin);
- printf("caracter b: ");
- the_char_b = getchar();
- printf("a: %c; b: %c\n", the_char_a, the_char_b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement