zoukankan      html  css  js  c++  java
  • C

    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;
    };


  • 相关阅读:
    让IT工作者过劳的13个坏习惯zz
    WPF Radio button的解决方案
    程序退出的各种方法,如何关闭多线程。
    文本框输入自动切换输入法问题
    在外部js文件中读取带母版页的子页当中控件的值
    Showwindow/FindWindow/PostMessage 转
    vb读取字节中的某一位
    C# 禁止windows程序重复运行的两种基本方法
    C# DllImport的用法(转)
    sqlserver存储过程中sql语句连接及datetime字段的处理
  • 原文地址:https://www.cnblogs.com/ruiy/p/4481185.html
Copyright © 2011-2022 走看看