Is it costlier to deallocate and then reallocate memory dynamically initialized with zero (for a fixed size array:- lenght of 255 ) compared to running an loop and making all its elements zero in C++?
A):- for(int i=0; i<256; i++){ arr[i]= 0; }
B):- int* array = new int[256]; delete[] array; int* array = new int[256];
Which among the above two i.e. A) or B) is more costlier in terms of time?