C + Queue + Pointer Problem

Status
You're currently viewing only bugbum1's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

bugbum1

Ars Scholae Palatinae
893
the code you included compiles without that warning on my system. i did have to assign temp=0; to get rid of uninitialized variable warning....

code:<HR>
Code:
#define MAXLEN 10<P>typedef struct QueueNodeTag
{
char data[MAXLEN];
struct QueueNodeTag * next;
} QueueNode;<P>typedef struct 
{
struct QueueNode *head;
struct QueueNode *tail;
} Queue;<P>void Insert (Queue *q, char *to_be_sent)
{
QueueNode *temp;<P>temp = 0;<P>	q->head = temp; // Special case for the first
	q->tail = temp; // element in the Linked List
}

if you e-mail me the whole file, i'll compile it to confirm, but your snipet compiles fine (also turned warning level to max to catch other things).
 

bugbum1

Ars Scholae Palatinae
893
oh, geez. i just saw the problem... sorry. i was using .cpp which let me get away with the problem - C .c is picky...

i see this error with .c file

tst.c(24) : warning C4133: '=' : incompatible types - from 'struct QueueNodeTag
*' to 'struct QueueNode *'
tst.c(25) : warning C4133: '=' : incompatible types - from 'struct QueueNodeTag
*' to 'struct QueueNode *'
 

bugbum1

Ars Scholae Palatinae
893
this seems to work... sorry about the original post (was using tst.cpp and it didn't catch the problem).


code:<HR>
Code:
#define MAXLEN 10<P>typedef struct QueueNodeTag
{
char data[MAXLEN];
struct QueueNodeTag * next;
} QueueNode;<P>typedef struct 
{
struct QueueNode *head;
struct QueueNode *tail;
} Queue;<P>void Insert (Queue *q, char *to_be_sent)
{
struct QueueNode *temp;<P>temp = 0;<P>q -> head = temp; // Special case for the first
q -> tail = temp; // element in the Linked List
}
 
Status
You're currently viewing only bugbum1's posts. Click here to go back to viewing the entire thread.
Not open for further replies.