PracticeDev/study_cpp/memset/memset_test.cpp

16 lines
327 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}