R
Ravikant
Hello,
Please check the following code .Let me know why its giving
the segmentation fault while running it.First it asks to enter the
name ,when entered it gives segmentation fault.
But if I dont use the insert() and written everything in
main(),it works fine.Please help me out.
#include<stdio.h>
typedef char* Name;
typedef struct node
{
Name name;
struct node *link;
}Data_node;
main()
{
insert();
}
insert()
{
Name Myname;
Data_node *p;
printf("Enter the name\n");
scanf("%s",Myname);
p = (Data_node *) malloc (sizeof (Data_node));
p->name = Myname;
printf("%s\n",Myname);
}
bye
Ravi
Please check the following code .Let me know why its giving
the segmentation fault while running it.First it asks to enter the
name ,when entered it gives segmentation fault.
But if I dont use the insert() and written everything in
main(),it works fine.Please help me out.
#include<stdio.h>
typedef char* Name;
typedef struct node
{
Name name;
struct node *link;
}Data_node;
main()
{
insert();
}
insert()
{
Name Myname;
Data_node *p;
printf("Enter the name\n");
scanf("%s",Myname);
p = (Data_node *) malloc (sizeof (Data_node));
p->name = Myname;
printf("%s\n",Myname);
}
bye
Ravi