i have this program that should print first name, middle name and last name. it almost works, but when I print strings, weird characters appear. I don't know how it's called, but instead of strings appearing, those characters appear. does anybody know why? I included parts of my program here:
typedef struct nodetag0{
char *fname;
char *mname;
char *lname;
}name;
typedef struct nodetag{
name mName;
}node;
main(){
node *root = NULL;
node tempo = (node*) malloc (sizeof(node));
fn = strtok(NULL, tmp);//taken from file
tempo->mName.fname = fn;
root = tempo;
printf("fname: %s",root->mName.fname);
}
I get the error, segmentation fault. I guess it's because of the printing?