Simple linked list

I am trying to create a simple linked list Here;the code I wrote:
typedef struct Move MOVE;
struct Move{
int player_no;
int from_cell[2];
int to_cell[2];
MOVE *next;};

MOVE *head=NULL;
MOVE *tail=NULL;
MOVE *tempos;

if ((tempos = malloc(sizeof(MOVE))) == NULL) { abort(); }

else tail->next=tempos;
I'm mot sure if what I wrote is right, and,, particularly I'm not sure if I initialized properly the from_cell and to_cell arrays.
I was also wondering how I can print all the elements of the structure.
Any help greatly appreciated!


  • [code]
    from_cell [0] = temprow;
    from_cell [1] = tempcol;
  • ok,that seems to be right. But how can I print the list,in order to be perfectly sure that it's correct?
  • [color=Blue]You need the sorting algorithm for linked lists. Search the web - you will find some code for that. I, personally, never use linked lists (poor performance on large lists), so I do not know.[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!