リスト構造のプログラムで
struct node {
int data;
struct node *next;
};
なる構造体を定義し、メモリを確保する際に、
struct node *p_new;
p_new=(struct node *)malloc(sizeof(struct node));
とC言語の本に載っています。しかしながら、別の本には、
p_new=(struct node *)malloc(sizeof(struct node)+4);
のように+4、あるいは+8などしているのですが、これは
なぜでしょうか?何のためでしょうか?教えていただけませんか?
いずれにしてもコンパイルは出来ますし、実行も正常にできます。