www.cnblogs.com/ruiyqinrui

开源、架构、Linux C/C++/python AI BI 运维开发自动化运维。 春风桃李花 秋雨梧桐叶。“力尽不知热 但惜夏日长”。夏不惜,秋不获。@ruiY--秦瑞

python爬虫,C编程,嵌入式开发.hadoop大数据,桉树,onenebula云计算架构.linux运维及驱动开发.

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  2912 随笔 :: 9 文章 :: 51 评论 :: 185万 阅读

precision精确 int width();int width(int w);返回当前宽度,设置宽度大小,宽度是指每一次输出中显示字符的最小数目;
向函数传递指针的缺陷在于函数现在可以对调用程序的结构变量进行修改,可以在函数中使用const关键字防止修改
void print_receipt(register Transaction const *trans);

Transaction compute_amount(Transaction trans) //返回值类型是结构体类型
{
trans.total_amount = trans.quantity * trans.unit_price;
return trans;
}
结构的一份拷贝作为参数传递给函数并被修改,然后一份修改后的结构拷贝从函数返回,所以这个结构被复制两次;
只修改返回值,而不是修改整个结构
float compute_total_amount(Transaction trans)
{
return trans.quantity * trans.unit_price;
}
current_trans.total_amount = compute_total_amount(current_trans);
void compute_total_amount(register Transaction *trans)
{
trans->total_amount = trans->quantity * trans->unit_price;
}
bit field;
位段的 declared defined和结构类似,成员是一个或多个位的字段,一个或多个字节字段
不同长度的字段实际存储在一个或多个整型变量中;
位段的声明和普通结构成员声明相同,位段成员必须声明为int,signed int OR unsigned int,成员名后面: 整数,整数指定该位段占用的位的数目;
int ruiy:5;
signed int ruiy:5;
位段中成员在内存中从左到右分配,还是? 未定!

bit filed
struct CHAR
{
unsigned ch    : 7;
unsigned font    : 6;
unsigned    : 19;
}; //声明位段数据类型
struct CHAR ch1;//使用上面定义的位段数据类型定义位段变量
访问整型值的部分内容
允许程序对寄存器不同位段进行访问
struct DISK_REGISTER_FORMAT {
unsigned    command    : 5;
unsigned    sector    : 5;
unsigned    track    : 9;
unsigned    error_code : 8;
unsigned    head_load : 1;
unsigned    write_protect : 1;
unsigned    disk_spinning : 1;
unsigned    error_occurred : 1;
unsigned    ready : 1;
};


posted on   秦瑞It行程实录  阅读(132)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
历史上的今天:
2014-05-06 cobbler常见问题
2014-05-06 yum KVM
www.cnblogs.com/ruiyqinrui
点击右上角即可分享
微信分享提示