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,009
    Likes Received:
    203
    Trophy Points:
    63
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice