printf()和scanf()函数的格式小结


自己经常忘记使用printf和scanf的函数格式


用scanf()函数从键盘接收十六进制字符是用%x就可以.

比如:

#include<stdio.h>
void main()
{int x;
printf("请输入0~9或a到f的字符:");
scanf("%x",&x);
printf("接收的十六进制字符为:%x\n",x);
}



用printf()函数输出十六进制字符,加上#,输出0x,02表示用0填充,2表示输出的位数;

printf("result1=%#010x,result2=%#010x;",result1,result2);


原文地址:https://www.cnblogs.com/HuaiNianCiSheng/p/3074719.html