A89: Re: initializing array in C


[Prev][Next][Index][Thread]

A89: Re: initializing array in C




Hi!

> How do I initialize all the values in an array to 0 by something like:
> 
> fill array[] with 0;
> 
> instead of:
> 
> array[]={0,0,0,0,0,....};

1.) In compile time (this is probably what do you want):

array[N]={};

where 'N' is the number of elements.

2.) In run time:

memset(array,0,N*sizeof(array[0]));

Zeljko Juric