参考博客:https://blog.csdn.net/qq_25406563/article/details/83303371
一、一般用于大的数据进行清0的操作,参考上述博客,整理清0数据操作,代码如下:
#include <iostream>
using namespace std;
int main()
{
char str[10];// 申请一个数组
str[9] = 'w';//将最后一个数组的数设置设置为'w'
memset(str,0,9);//将前面的9个数进行赋值为0的操作
for (int i = 0; i < 10;i++)
{
cout << str[i] << " ";//将里面的数进行打印出来
}
system("pause");
while (1);//最后结果就是前面是9个0,最后一个值为w
return 0;
}
最后结果如下图: