A simple way to initialize the struct, which you will often encounter in Linux Kernel is :
Consider a struct :
struct temp {
int a;
int b;
};
To initialize the struct,
struct temp try = {.a = 2};
struct temp try1 = {.a = 3, .b =4};
struct temp try2 = {.a=4,};
All are valid initializations.
Imp!! However, this is allowed only for initialization while declaration, not later.
i.e. struct temp try;
try = {.a=2,.b=3};
is not allowed
Search This Blog
Showing posts with label struct initializtion. Show all posts
Showing posts with label struct initializtion. Show all posts
Wednesday, September 9, 2009
Subscribe to:
Posts (Atom)