Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How can C language control the input number to keep only six decimal places? For example, I just entered 0. 1234568, and the program still counts 0. 123456.
How can C language control the input number to keep only six decimal places? For example, I just entered 0. 1234568, and the program still counts 0. 123456.
Scanf("%8f ",& Answer

The general format of the scanf () function is: scanf ("format string", input item header address table).

The general form of format control of scanf is:%? The control character in [width][F | N][h | l]type *[] is optional * "*", which means that the input item is not given any variables after reading, that is, the input value is skipped. This is still useful for reducing memory overhead. Skip the unnecessary characters directly and avoid applying for the useless variable space * "width" to indicate the length of the input read-in characters. For integer, intercept the number with the corresponding width and assign it to the corresponding variable in the following list; For character types, after reading characters of corresponding length, the first character is assigned to the corresponding variable, and the rest characters are automatically discarded. For example, scanf ("%2d% 3d ",&a, & AMPB); If the input is 12345, assign 12 to A and 45 to B; Scanf("%2c%3c ",&i, & b); If the input is 12345, assign' 1' to a, and assign' 3' to b * F, n, h, l, which respectively represent far pointer, near pointer, short integer and long integer. For _int64, the corresponding control character is ll or I64 * "Type character" is d-input decimal integer, o-input octal integer, x-input hexadecimal integer, u-input unsigned decimal integer F or e-input real number (decimal form or exponential form), c-input single character, and s-.