structure initialization
---------------------------------
---------------------------------
typedef struct __t_obj
{
char a;
int b;
char* str;
}obj;
/*GCC allows the following initialization methods*/
obj temp1 = {'X', 123, "this is a string"};
//complete initialization
obj temp2 = {.a = 'X', .str = "this is a string"};
//partially initialization
obj temp3; temp3.a = 'X'; temp3.b = 123;
/*VC2010 allows the following initialization methods*/
obj temp1 = {'X', 123, "this is a string"};
//complete initialization obj temp3; temp3.a = 'X'; temp3.b = 123;
No comments:
Post a Comment