I am complete beginner in C and need help with saving strings in structs.
(I tried multiple ways to have it done but program prints nothing or i got (0xC0000005) or program shuts down.. (I tried using pointer as a parameter but effect is the same-or using scanf straightly for text.line and etc ). I would be glad if somebody explained me simply how it should be done - I got feeling that i still dont fully understand idea of pointers and thats the problem ;q.
typedef struct label{
char *line;
}label;
void save_line(label text){
printf("Write your name\n");
char *helper=malloc(30 * sizeof *helper);
scanf("%s", helper);
strcpy(text.line, helper);
}
void main(){
label text;
save_line(text);
printf("%s", text.line);
}