#include <stdio.h>
using namespace Std;
/*
Www.quzhuanpan.com
Reprint please be sure to inform
*/
int main ()
{
int i=0;
Char ch[20];
GetChar ();
for (i=0; i<10; i++)
{
Ch[i]=getchar ();//Subsequent characters are continuously read, so the first character cannot be hit.
}//Read the flag is to press ENTER, and the carriage return also as a character
for (i=0; i<10; i++)
{
printf ("%c", Ch[i]);
}
Puts (CH);
return 0;
}
/*getchar is implemented by a macro: #define GETCHAR () getc (stdin). The GetChar has a return value of type int.
When the program calls GetChar. The program waits for the user to press the key.
Characters entered by the user are stored in the keyboard buffer. Until the user presses ENTER (the carriage return character is also placed in the buffer).
When the user types a carriage return, GetChar begins to read one character at a time from the stdin stream. The return value of the GetChar function is
The ASCII code of the first character entered by the user, such as an error return-1, and the user-entered word echo to the screen. If the user presses ENTER
Before entering more than one character, the other characters inode remain in the keyboard buffer, waiting for subsequent getchar calls to read. That is to say,
Subsequent GetChar calls do not wait for the user to press the key, but to read the characters in the buffer until the characters in the buffer have finished reading.
Just wait for the user to press the key. */
The use of GetChar, C language