C语言输入输出的各种常见问题
下面是我编写的代码,代码里的注释都是我在复习这次C语言输入输出所写的,英文,,,emm,我在有道词典翻译的,一般没啥大问题,有啥问题欢迎提问,有啥错误希望各位大佬指出纠正。
/*
programmer: yang yang chen
time:2020/8/12
*/
#include<stdio.h>
#include<conio.h>
int main( void ){
int number;
float number1;
int a, b;
char c;
printf( "please enter a character:\n");
c = getchar();
printf( "c(getchar): %c\n", c);
printf( "please enter a character:\n");
c = getch();
printf( "c(getch): %c\n", c);
printf( "please enter a character:\n");
c = getche();
printf( "\nc(getche): %c\n", c);
printf( "please enter the int number and float number1:\n");
a = scanf( "%d%*c%f", &number, &number1 );
printf( "\na: %d", a);
printf( "Octal form: %#o\nDecimal form: %d\nHexadecimal form: %#x\n", number, number, number );
printf( "Unsigned integer form: %u\n06: %06d\n", number, number );
printf( "5.2f: %5.2f\nE: %e\n" , number1, number1 );
b = printf( "*: %*f\n", number, number1);
printf( "%d\n", b);
printf( "-md: %-10d\nmd: %10d\n", number, number );
return 0;
}
/*Conclusion
printf():
%d & %i:
Output in decimal.
%ld:
Output long integer data.
%md & %0md & %-md & -0md:
The m represents the output field width, insufficient padding of space or zero,
the symbol indicates the left hand side.
%u & %U:
Output an unsigned integer.
%c:
Output a character.
%f:
Output a real number.
%.mf:
Keep m bits for the output real numbers.
%o & %#o:
Output in octal integer from, the # express the zero.
%s:
Output string.
%x & %X & %#x &%#X:
Output an integer in hexadecimal format, case sensitive, and the # express the zero.
%e:
Output real numbers as exponents.
%*:
Jump over.
scanf():
%*: Accept but do not store.
return value problem:
printf(): Returns the number of characters printed.
scanf(): Returns the number of normal input objects.
getchar & getch & getche:
1. getchar in stdio.h.
2. getch & getche in conio.h.
3. getchar: return a character, displayed on the screen, and end with a line break.
4. getch: return a character, not displayed on screen, and don't wrap.
5. getche: return a character, displayed on screen, and don't wrap.
*/