memset function in c language

后端 未结 3 640
刺人心
刺人心 2021-01-31 11:21

I am studying the memset function now, but all the examples are regarding to char array as following:

char a[100];
memset(a, 0, 100);

it will s

3条回答
  •  萌比男神i
    2021-01-31 11:59

    It can be applied to any array. The 100 at the end is the size in bytes, so a integer would be 4 bytes each, so it would be -

    int a[100];
    memset(a, 0, sizeof(a)); //sizeof(a) equals 400 bytes in this instance
    

    Get it? :)

提交回复
热议问题