Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   array of structures (http://www.go4expert.com/forums/array-of-structures-t27339/)

jose_peeterson 12Dec2011 20:11

array of structures
 
Dear all,
can someone tell me how to INITIALIZE array of structures? i mean like this
Code:


struct appointments appo[24] = {'\0',0,0};

this only initializes appo[0] others are not initalized properly.

so how can i initialize all appo[0] through appo[23] with the SAME initialization?

thanks.

xpi0t0s 13Dec2011 04:14

Re: array of structures
 
If you just want to initialise the whole lot to zeros the easiest way is to use memset.
Code:

memset(&appo[0],0,24*sizeof(struct appointments));


All times are GMT +5.5. The time now is 10:06.