I can't understand why this simple code doesn't run without causing a segmentation fault on linux :
#include <stdlib.h>
struct entry
{
int value;
};
void initEntry(struct entry *entry)
{
entry = malloc(sizeof(struct entry));
entry->value = 0;
}
int main()
{
struct entry *list;
initEntry(list);
list->value = 5;
}
I can run the program after removing the last instruction (list->value = 5;
)
I compile with :
gcc main.c -o main