I am new to C and learning structs. I am trying to malloc a char pointer with size 30 but it is giving a segmentation fault(core dump). I searched it on the interne
malloc
Check for NULL values in return of malloc() function.
malloc()
Also str *p; < is not initialised.
str *p;
initialize p as str *p = malloc(sizeof(str));
str *p = malloc(sizeof(str));