In addition, a pair of getchar and putchar operate on characters and character variables, and a pair of scanf and printf can input and output various types of variables. Let ch be a char variable and I be an integer variable. Usage is as follows.
input:c = getchar(); Scanf("%c ",& ampCh) (note &; Will often forget); scanf("%d ",& ampI);
Output: putchar (c); printf("%c ",ch); printf("%d ",I);
Getchar () can accept all kinds of characters, including space carriage return, and the corresponding putchar can output a character, such as:
putchar(' a '); Will type a on the screen, putchar can also type the value that already exists in the character variable ch:
c = ' aputchar(c); The screen will also print an a, scanf and printf. Nothing special, just don't type it wrong. In addition, when inputting multiple variables, such as: scanf("%c, %d ",ch, i); At this time, you should also enter a comma, first enter' a', then enter',', and then enter 1. That's all.