当前位置:网站首页>2.57 - Programming show_ short, show_ Long and show_ Double, which print the byte representation of C language objects of types short, long and double respectively. Please try running on several machi
2.57 - Programming show_ short, show_ Long and show_ Double, which print the byte representation of C language objects of types short, long and double respectively. Please try running on several machi
2022-04-23 00:35:00 【gan-di】
#include <stdio.h>
//A byte pointer refers to a sequence of bytes
typedef unsigned char * byte_pointer;
//The input is a byte pointer and a byte number
void show_bytes(byte_pointer start, size_t len) {
size_t i;
for (i = 0; i < len; i++) {
//A storage unit holds one byte
printf("%.2x ", start[i]);
//Output in hexadecimal format with at least two digits
}
printf("\n");
}
//show_short
void show_short(short x) {
show_bytes((byte_pointer)&x, sizeof(short));
}
//show_long
void show_long(long x) {
show_bytes((byte_pointer)&x, sizeof(long));
}
//show_double
void show_double(double x) {
show_bytes((byte_pointer)&x, sizeof(double));
}
void show_pointer(void *x) {
show_bytes((byte_pointer)&x, sizeof(void *));
}
void test_show_bytes(int val) {
//Prints byte representations of the three target types
int ival = val;
short stval = (short)ival;
long lval = (long)ival;
double dval = (double)ival;
show_short(stval);
show_long(lval);
show_double(dval);
}
int main() {
int test = 328;
test_show_bytes(test);
return 0;
}
win64 in long Occupy 4 Bytes

linux64 in long Occupy 8 Bytes

版权声明
本文为[gan-di]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222149134583.html
边栏推荐
- 深度学习基础学习-残差
- 2022年4月22日,第15天
- 【图像分类】用最简单的代码复现SENet,初学者一定不要错过(pytorch)
- Linear basis (various templates + examples)
- Research Progress on remote sensing of vegetation phenological parameters (good article sharing)
- Add a route between two CX controllers of Beifu
- 层次分析法软件操作步骤(yaahp)
- Error runtimeerror when MySQL runs workbench
- How do programmers find jobs? What if it becomes more and more difficult for programmers to find a job?
- repeat_ map mp. find() + mp. erase()
猜你喜欢

Bypass network restrictions through RDP tunnel

Steps to apply for a CA certificate

ArcGIS 计算地块容积率

Beginner MCU lights up the first peripheral -- led light

植被物候參數遙感研究進展(好文分享)

洛谷P2241统计方形

(transfer) how winscp (SSH FTP client) generates the key to log in Linu

国产化浪潮下TiDB解决的痛点问题

How do programmers find jobs? What if it becomes more and more difficult for programmers to find a job?

Pain points solved by tidb under the wave of localization
随机推荐
MySQL built-in function
MySQL -- table operation
Deletes all specified elements in the vector
L2-010 排座位 (25 分) 并查集
L2-035 完全二叉树的层序遍历 (25 分)
Solution for error reporting of biff el6631 and Siemens communication PROFINET
TiDB 在连锁快餐企业丨海量交易与实时分析的应用探索
The story of tidb and I met unprepared, but I wanted to say how lucky I was to meet you
湖泊的水色、水环境、水文遥感的区别
Symbolization of ArcGIS surface tin surface data
接口文档生成工具ApiPost 绝了
【AI视野·今日Sound 声学论文速览 第四期】Thu, 21 Apr 2022
[image classification] - come on, let's do this bowl of efficientnet combat (pytoch)
repeat_ String delete some characters
Install authorizationpolicy and envoyfilter
植被物候参数遥感研究进展(好文分享)
市场格局进入重构期,ESP频繁「召回」,中国供应商「乘势而上」
深度学习基础学习-RNN与LTSM
C语言 #和 ##
C console application flash when running solution