c - Arthmetic operation in structure -


is possible in c language:

typedef struct s {     char a;     int b;     int c = this.a * 60 + this.b; } s; 

such type of structure usefull in code.

no, in c can't assign remember value in declaration, compilation time error.

but 1 solution can suggest(may like):

#define init(this, a, b)  {a, b, (this).a * 60 + (this).b} 

and call it:

s s = init(s, '5', 6); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -