I'm getting a segmentation fault on the last line noted below. I'm comparing two strings.
Code:
struct node {
char name[25];
char address[65];
float amount;
struct node * next;
};
typedef struct node item;
item * curr, * head, * tail, * new;
void insert(char *name_, char *address_, float amount_){
new = (item *)malloc(sizeof(item));
strcpy (new->name, name_ );
strcpy (new->address, address_ );
new->amount = amount_;
........................
printf("%s, ", new->name); printf("%s\n, ", head->name);
//the above print statements where put in as tests. They print two names.
//But, the very next line below produces an error: "segmentation fault"
if (strcmp(new->name, head->name) < 0){
...
...