#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[1010];
memset(arr,1,sizeof(arr));
cout<<arr[1]<<endl;
return 0;
}
I am trying to initialise the array with value of 1. I expect my o/p to be 1. But I got some random number(16843009) as o/p of program.I am not understanding what's wrong with the code???
I am getting the expected answer while I am trying to initialise the array with values -1 and 0. Is it possible to initilise the int array using memset with value other than -1 and 0?????