当前位置:网站首页>C language -- printf print base prefix
C language -- printf print base prefix
2022-06-29 16:14:00 【Please trust me】
problem
Here is a tip to share with you , For some topics, we are required to print the following format
octal : 020 0144 0213
Hexadecimal :0x231 0x231 0x64
It's simple , We just need to print at the end , Declare the print type of the printed variable .
octal :%o
Hexadecimal :%x
Unfortunately, the final result is wrong !!!
as follows 
The result we print out has no base prefix
What shall I do? ?
solve
Use C Language specifier , To print these prefixes
Code
#include<stdio.h>
/* octal : %#o Hexadecimal : %#x or %#X */
int main(void)
{
int x=100;
printf("dec = %d; octal = %#o ; hex = %#x or hex = %#X \n",x,x,x);
return 0;
}
result

It is also a small skill , What if it works one day
边栏推荐
- Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
- A. Print a Pedestal (Codeforces logo?)
- 蓝桥杯2015年CA省赛(填坑中)
- 基于JSP实现毕业设计选题系统
- Volcano engine was selected into the first "panorama of edge computing industry" in China
- Magento 和 WordPress 的区别
- leetcode:139. Word splitting [DFS + memory]
- MySQL基础——事务
- R语言DALEX包的explain函数生成指定分类预测机器学习模型解释器、predict_parts函数基于oscillations方法分析对于指定的某一条样本、每个变量对于预测结国的贡献程度
- mysql数据库基础:数据类型介绍
猜你喜欢

BS-GX-018 基于SSM实现在校学生考试系统

元数据管理Apache Atlas编译集成部署及测试

leetcode:232. 用栈实现队列【双栈,一个辅助一个模拟队列】

Autodesk Revit 2023软件安装包下载及安装教程

Nanjing University: Discussion on the training scheme of digital talents in the new era

支付宝“安全锁”入选信通院“护童计划”优秀案例:超过33万用户已开通游戏保护

Tutorial | fNIRS data processing toolkit homer2 download and installation

加速智能驾驶项目落地?你还缺一套真值测评系统

leetcode:535. TinyURL 的加密与解密【url和id的映射,id自增】

MySQL常用语句和命令汇总
随机推荐
Which version of JVM is the fastest?
[proteus simulation] 8-bit nixie tube dynamic scanning display change data
如何在 WordPress 中创建联系表格?
Digital tracking analysis of insurance services in the first quarter of 2022
Volcano engine was selected into the first "panorama of edge computing industry" in China
数学知识复习:第一型曲线积分
【大家的项目】 Rbatis ORM官网上线
Key wizard play monster learning - multi window and multi thread background judgment of character, pet blood volume and pet happiness
scratch报时的公鸡 电子学会图形化编程scratch等级考试一级真题和答案解析2022年6月
Cerebral Cortex:从任务态和静息态脑功能连接预测儿童数学技能
leetcode:535. Encryption and decryption of tinyurl [mapping of URL and ID, ID self increment]
Daily / June 29, 2022: where is Li Feifei's focus on "embodied intelligence"?
[rust daily] rust 2021 stability
教程|fNIRS数据处理工具包Homer2下载与安装
CV5200自组网远程WiFi模组,无人机无线图传应用,高清低时延方案
Key sprite fighting monsters - window binding protection skills and click skills
A. Beat The Odds
按键精灵打怪学习-窗口绑定技能
工具链赋能百家,地平线开启智能驾驶量产的“马太效应”
C语言——printf打印进制前缀