C linked list manipulations
I have to insert, delete, print all, and print specific members of a linked list.
typedef struct tnode
{
int wayptnum;
double x;
double y;
double heading;
double distance;
struct tnode *next;
}gpsnode;
That is my link list struct definition. I want to include a next that indicates the location of the next record. Why does this have to be so elaborate? Since the next entry is a pointer - doesn't that mean it is just an integer value of a memory location. So, why not have int next instead?
while ( fscan(fileptr,"%c%i%d%d",cmd,waypt,x,y) != EOF )
{
switch (cmd)
{
case 'a': insert(gpsnode **head, gpsnode data);
case 'P': prntall(gpsnode **head);
case 'p': prnt(gpsnode **head, gpsnode data);
case 'd': delte(gpsnode **head, gpsnode data);
default: printf("%c",cmd," was not a valid option.");
}
This is my routine for dealing with an incoming command from a file. The compiler gives a parse error.
So, what's wrong with case 'a': insert(gpsnode **head, gpsnode data); ?
and why am I passing a pointer to a pointer? Why not just pass the address of the head of the linked list?
Do I need more to pass more arguments? Am I legally passing arguments that are legal? As I see it, I only need to pass the start of the list plus the data that needs to be printed, deleted, or inserted.
After main, I plugged in some function as placeholders.
return(0);
}
insert(gpsnode **head, gpsnode data)
{
int dummy;
};
I get a parse error. Why is the syntax illegal?
Thanks.
By OTA: David Grant, MASc
OTA Rating: 4.8/5
Your Price: $2.19 (original value ~$11.97)
What's included:
Page generated in 0.0112 seconds