编辑代码

#include <stdio.h>
int main () {
    unsigned short offset = 4;
    unsigned char test[10];
    for (int i = 0; i < 10; i++)
    {
        test[i] = 'a' + i;
    }
   
    // for (int i = 0; i < 10; i++)
    // {
    //     printf("test[i] = %c\r\n", test[i]);
    // }

    int len = sizeof(test) / sizeof(test[0]);
    // printf("len = %d\r\n", len);

    memset(test + offset, 0, (len - offset) * sizeof(unsigned char));
    for (int i = 0; i < 10; i++)
    {
        printf("test[i] = %c\r\n", test[i]);
    }

    return 0;
}