#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
int arr[10] = { 1,2,3 };
for (int i = 0; i <= 5; i++)
{
cout << arr[i];
}
cout << endl;
memset(arr, 0, sizeof(arr));//格式
for (int i = 0; i <= 5; i++)
{
cout << arr[i];
}
cout << endl;
memset(arr, -1, sizeof(arr));
for (int i = 0; i <= 5; i++)
{
cout << arr[i];
}
cout << endl;
return 0;
}
只能初始化为0或-1;
输出为:
123000
000000
-1-1-1-1-1-1