# 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

Relevance

- QuentinLv 74 weeks agoBest 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 71 month 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"

Still have questions? Get your answers by asking now.

... You should have used the same number of fingers each time. Listen to 'Brillaint_Moves' -- he's trying to help you out.