c language scanf input character format

c language input string scanf

c language input string scanf:

With chara; a is the pointer to the first element of this array, &a is the pointer to this array; because the pointer to the first element of a one-dimensional array and the pointer to this array are at the same address, the difference is that a+1 points to a and &a+1 points to a, while &a+1 points to a. amp;a+1 points to a. But &a and a have the same “value”, just different types.


scanf is a standard library function in the C language, the main role is to receive user input data. scanf is an input function in the C language, you can get the user input from the keyboard, and printf output function is just the opposite. scanf’s input format is a variety of things, use according to the situation need to select the most commonly used is the decimal integer type.

The first two scanf: enter an integer, press enter, scanf will read the keyboard input, and assign the data to c (or d); the last two scanf: are the same function, the input format is different, for scanf (), the format of the input data and the format of the control string to maintain consistency. For example: enter 15, 24 return, enter 15, 24 return, the same assign the value to c and d respectively.