zoukankan      html  css  js  c++  java
  • C语言位域使用

    
    
     

      信息的存取一般以字节为单位。实际上,有时存储一个信息不必用一个或多个字节,例如,“真”或“假”用0或1表示,只需1位即可。

       在计算机用于过程控制、参数检测或数据通信领域时,控制信息往往只占一个字节中的一个或几个二进制位,常常在一个字节中放几个信息

    
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <limits.h>
    #include <time.h>
    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>
    #include <signal.h>
    #include <string.h>
    #include <stdlib.h>
    struct usb
    {
        int sample_rate;
        int sample_bits;
        unsigned int connect:1;  //int 会出现问题  -1  0xffffffff
    };
    //0-8 ?
    int main()
    {
        struct usb usb_device;
        usb_device.connect = 1;
        printf("usb device is length is %d ",sizeof(usb_device.sample_bits));
        //printf("usb device is length is %d ",sizeof(usb_device.connect));
        printf("usb device is %d ",usb_device.connect);
        //printf("usb undef is %d ",usb_device.undef);

        for(;;);
        return 0;
    }
     

    一勤天下无难事。
  • 相关阅读:
    POJ 2773 Happy 2006------欧几里得 or 欧拉函数。
    Candies
    subway(dijkstra以最短时间代替最短路)
    昂贵的聘礼
    LightOJ 1074
    SPFA以及各种优化
    Making Huge Palindromes (Manacher)
    Making Huge Palindromes (KMP处理回文串)
    AC自动机基础
    扩展KMP
  • 原文地址:https://www.cnblogs.com/nowroot/p/13765423.html
Copyright © 2011-2022 走看看