Thank you for your support in solving my previous problems. Now I am studying self-relational structures. I wrote the following code:
#include <stdio.h>
int main()
{
system("clear");
struct node
{
int x;
struct node *next;
} p1;
printf(" \nthe address of node1 = %u",& p1);
printf(" \n\nthe size of node 1 = %d",sizeof( p1));
printf("\n\n the size of info part = %d",sizeof(p1.x));
printf("\n\n the size of pointer part = %ld",sizeof(p1.next));
printf("\nthe size of node is = %d\n",sizeof(struct node));
return;
}
A program compiled with several warnings like:
warning: format '% u expects type' Unsigned int, but argument 2 has type 'struct node *
Every time I do something with a pointer, this warning is generated. What is the problem? I do not know that. Can someone explain why this is happening on Linux (specifically)?
My second question is that when the program starts, it shows the size of the structure 16, and int takes 4 bytes (Ubuntu 10), and the pointer is 8 bytes. Then why does it show a structure size of 16 bytes?