I thought by setting the first element to a null would clear the entire contents of a char array.
char my_custom_data[40] = "Hello!";
my_custom_data[0] = '\0';
However, this only sets the first element to null.
or
my_custom_data[0] = 0;
rather than use `memset`, I thought the 2 examples above should clear all the data. Jared, why did you set the c++ tag? he talked about "C" and did not add any C++ related tags.
以上就是clearing a char array c的详细内容,更多请关注web前端其它相关文章!