C
Chris McDonald
I've been trying to wean myself off using parentheses after the sizeof
operator (and after the return keyword, too), but my understanding is
challenged by the 4th use of sizeof in the following code:
#include <stdio.h>
struct {
int i;
char *p;
} var;
typedef struct {
int i;
char *p;
} TYPE;
int main(int argc, char *argv[])
{
printf("1: %d\n", sizeof var);
printf("2: %d\n", sizeof(var));
printf("3: %d\n", sizeof TYPE);
printf("4: %d\n", sizeof(TYPE));
return 0;
}
I understand that (TYPE) is not a value, so is the 3rd use of sizeof a
sort of 'special case' of what sizeof permits?
(gcc v4.0.1 and earlier, just to make this possibly OT)
A bit confused; Thanks,
operator (and after the return keyword, too), but my understanding is
challenged by the 4th use of sizeof in the following code:
#include <stdio.h>
struct {
int i;
char *p;
} var;
typedef struct {
int i;
char *p;
} TYPE;
int main(int argc, char *argv[])
{
printf("1: %d\n", sizeof var);
printf("2: %d\n", sizeof(var));
printf("3: %d\n", sizeof TYPE);
printf("4: %d\n", sizeof(TYPE));
return 0;
}
I understand that (TYPE) is not a value, so is the 3rd use of sizeof a
sort of 'special case' of what sizeof permits?
(gcc v4.0.1 and earlier, just to make this possibly OT)
A bit confused; Thanks,