# how do i initialise my array again in c?

if my array already contains a few values, what is the fastest and most efficient way to delete everything in my table?

i want to do it in my main function, but the array is score[num], where num can be any number but only a total of 100 values. so in this case i cannot use

for(i = 0; i <= 100; i++) {

score[i] = 0;

}

since the 'num' isnt values from 1 to 100

help please!!

### 3 Answers

- QuentinLv 710 months agoFavorite Answer
const int n = 0; // or any value to set them to

const int count = 100; // or any count of values

memset(score, 0, count*sizeof(int)); // all at once

Or consider SecureZeroMemory.

- brilliant_movesLv 710 months ago
int i;

for(i = 0; i < 100; i++) {

... score[i] = 0;

}

... will set every value in array "score" to zero. "i" varies from 0 to 99 inclusive. Use "< 100" NOT "<= 100"

- Anonymous10 months ago
I'm gonna get the one day I'll be getting