PracticeDev/study_cpp/memset/memset_test.cpp

16 lines
327 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
#include <iostream>
#include <string.h>
using std::cout;
using std::endl;
int main()
{
int num[8];
memset(num,1,32); //一个int是4个字节的8个int是32个字节所以首先要赋值的长度就不应该为8而是32
for(int i=0;i<8;i++)
{
cout << num[i] << " " << endl;
}
return 0;
}