Answers for "how to initialize an array to value 0 or -1"

1

Initialize all the elements of array to 0

int myArray[10] = { 0 }; // all elements 0
Posted by: Guest on April-30-2021
0

how to initialize an array to value 0 or -1

int arr[10001];
memset(arr,-1,sizeof(arr));

int arr[m][n];
memset(arr,-1,sizeof(arr));


//NOTE:- memset can intialize the array or vector with value -1 or 0 only.
Posted by: Guest on February-03-2022

Code answers related to "how to initialize an array to value 0 or -1"

Browse Popular Code Answers by Language