Using sizeof operator on a typedef-ed struct
Posted
by
sskanitk
on Stack Overflow
See other posts from Stack Overflow
or by sskanitk
Published on 2012-10-16T22:55:37Z
Indexed on
2012/10/16
23:00 UTC
Read the original article
Hit count: 284
This might be something too obvious. However, I couldn't find the specific answer though many stackoverflow threads talk about different aspects of this.
typedef struct _tmp {
unsigned int a;
unsigned int b;
} tmp;
int main()
{
int c=10;
if (c <= sizeof tmp) {
printf("less\n");
} else {
printf("more\n");
}
return 0;
}
I compile this prog as -
g++ -lstdc++ a.cpp
I get an error -
expected primary-expression before ‘)’ token
I think I am missing something very obvious and straightforward. But can't seem to pinpoint it :-/
Thanks!
© Stack Overflow or respective owner