This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Struct initializarion method

recently on a web, i came across following initialization of structure.

MY_TYPE a = { .flag = true, .value = 123, .stuff = 0.456 };

The poster wrote that it is allowed in ANSI C99 standard.
But when i compiled it in Keil, it returned error.

Does keil not follow C99 standard?
how do i initialize a structure inside a structure?

  • how do i initialize a structure inside a structure?

    typedef struct MemDet
    {
            char    name[25];
            char    surname[25];
            float   height;
    }MemberDetails;
    
    
    typedef struct mem
    {
            MemberDetails   Dhaval;
            MemberDetails   Andy;
            MemberDetails   Per;
    }Members;
    
    
    static Members keilforum = {{"Dhaval", "Solanki", 5.9}, {"Andy", "Andy", 5.10}, {"Per", "Per", 5.9}};
    
    
    
    
    

  • static Members keilforum = {{"Dhaval", "Solanki", 5.9}, {"Andy", "Andy", 5.10}, {"Per", "Per", 5.9}};

    need not be static.