Aaron Replogle

USING DATA STRUCTURES/MALLOC in CW 5.7.0

Discussion created by Aaron Replogle on Oct 23, 2006
Latest reply on Oct 26, 2006 by no name
I am trying to create a simple structure with a pointer to it and I can't even get it to compile. I am assuming that this sort of coding is possible...what I would eventually like to do is have a linked list of items that I hard code at the start of the program and reference throughout. Here is what i have:

struct Item_Struct {
char Text[30];
char Price[6];
char BMP_NUM[3];
char BUT_NUM[3];
struct Item_Struct *Next;
};

struct Item_Struct *Head = NULL;

Head = malloc(sizeof(struct Item_Struct));
Head->Text = "Hamburger";
Head->Price = "$5.99";
Head->BMP_NUM = "45";
Head->BUT_NUM = "45";
Head->Next = NULL;

Outcomes