1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

array of structures

Discussion in 'C' started by jose_peeterson, Dec 12, 2011.

  1. jose_peeterson

    jose_peeterson New Member

    Joined:
    May 19, 2011
    Messages:
    56
    Likes Received:
    1
    Trophy Points:
    0
    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.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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));
    
     

Share This Page