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

/*******************************************************************
 *   > File Name: char_test.c
 *   > Author: fly
 *   > Mail: [email protected]
 *   > 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;
}
发布了56 篇原创文章 · 获赞 12 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/I_feige/article/details/103736101