C语言 | 获取一个数组的长度

/*******************************************************************
 *   > File Name: char_test.c
 *   > Create Time: 2019年12月27日 星期五 16时30分51秒
 ******************************************************************/

#include <stdio.h>


char SCSIInquiryData[] = {
    0x00,//  // Peripheral usb_slave Type: direct access usb_slaves  0x05,//
    0x80,   // Removable: UFD is removable
    0x02,   // ANSI version
    0x02,   // Response Data Format: compliance with UFI
    //  0x00,   // Additional Length (Number of UINT8s following this one): 31, totally 36 UINT8s
    0x1F,
    0x00, 0x00, 0x00,   // reserved
    'N',    // -- Vender information start
    'B',    //
    'D',    //
    'V',    //
    'R',    //
    '1',    //
    '2',    //
    '2',    // -- Vend Information end
    'H',    // -- Production Identification start
    'D',    //
    'A',    //
    '-',    //
    'M',    //
    'S',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    // -- Production Identification end
    0x31,   // -- Production Revision Level start
    0x2e,   //
    0x30,   //
    0x30    // -- Production Revision Level end
};

char SCSIInquiryData_MS[] = {
    0x00,//  // Peripheral usb_slave Type: direct access usb_slaves  0x05,//
    0x80,   // Removable: UFD is removable
    0x02,   // ANSI version
    0x02,   // Response Data Format: compliance with UFI
    //  0x00,   // Additional Length (Number of UINT8s following this one): 31, totally 36 UINT8s
    0x1F,
    0x00, 0x00, 0x00,   // reserved
    'N',    // -- Vender information start
    'B',    //
    'D',    //
    'V',    //
    'R',    //
    '1',    //
    '2',    //
    '2',    // -- Vend Information end
    'H',    // -- Production Identification start
    'D',    //
    'A',    //
    '-',    //
    'M',    //
    'S',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    // -- Production Identification end
    0x31,   // -- Production Revision Level start
    0x2e,   //
    0x30,   //
    0x30    // -- Production Revision Level end
};

char SCSIInquiryData_UPDATE[] = {
    0x00,//  // Peripheral usb_slave Type: direct access usb_slaves  0x05,//
    0x80,   // Removable: UFD is removable
    0x02,   // ANSI version
    0x02,   // Response Data Format: compliance with UFI
    //  0x00,   // Additional Length (Number of UINT8s following this one): 31, totally 36 UINT8s
    0x1F,
    0x00, 0x00, 0x00,   // reserved
    'N',    // -- Vender information start
    'B',    //
    'D',    //
    'V',    //
    'R',    //
    '1',    //
    '2',    //
    '2',    // -- Vend Information end
    'H',    // -- Production Identification start
    'D',    //
    'A',    //
    '-',    //
    'U',    //
    'P',    //
    'D',    //
    'A',    //
    'T',    //
    'E',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    //
    ' ',    // -- Production Identification end
    0x31,   // -- Production Revision Level start
    0x2e,   //
    0x30,   //
    0x30    // -- Production Revision Level end
};

int main(int argc, char* argv[])
{
    int len1 = 0;
    len1 = sizeof(SCSIInquiryData)/sizeof(char);
    //len1 = sizeof(SCSIInquiryData)/sizeof(SCSIInquiryData[0]);
    printf("len1 = %d\n", len1);

    int ii = 0;
    for(ii = 0; ii < len1; ii ++)
    {
        printf("%d--[%c]\n", SCSIInquiryData[ii], SCSIInquiryData[ii]);
    }

    puts("1=============================================================");

    for(ii = 0; ii < sizeof(SCSIInquiryData_UPDATE)/sizeof(char); ii ++)
    {
        printf("%d--[%c]\n", SCSIInquiryData_UPDATE[ii], SCSIInquiryData_UPDATE[ii]);
    }

    puts("2=============================================================");
    for(ii = 0; ii < sizeof(SCSIInquiryData)/sizeof(char); ii ++)
    {
        SCSIInquiryData[ii] = SCSIInquiryData_UPDATE[ii];
        printf("%d--[%c]\n", SCSIInquiryData[ii], SCSIInquiryData[ii]);
    }

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值