Sadistictoaster
Still Fresh
- Joined
- Sep 12, 2006
- Messages
- 22
Hey
I've set up some linked lists in a program i'm working on , but am having problems using functions with them. The linked lists work fine as long as they stay in the main function : so they're not at fault
struct node
{
int x;
int y;
node *next;
};
is the linked list.
addshot(current,112 , 25); invokes it
void addshot(node *current,int x , int y)
{
current->next = new node;
current = current->next;
current->x = x;
current->next = 0;
}
I've got to admit , I've never really got the hang of pointers ( too much BASIC in my youth ) , but this looks like it should be ok : but am never sure if I need a return or not when dealing with pointers.
I did have a few cracks at going the addshot function with return values , but they'd either not compile , the program would not run , or I would get the same nothing happening as I do with the original function.
Many Thanks
I've set up some linked lists in a program i'm working on , but am having problems using functions with them. The linked lists work fine as long as they stay in the main function : so they're not at fault
struct node
{
int x;
int y;
node *next;
};
is the linked list.
addshot(current,112 , 25); invokes it
void addshot(node *current,int x , int y)
{
current->next = new node;
current = current->next;
current->x = x;
current->next = 0;
}
I've got to admit , I've never really got the hang of pointers ( too much BASIC in my youth ) , but this looks like it should be ok : but am never sure if I need a return or not when dealing with pointers.
I did have a few cracks at going the addshot function with return values , but they'd either not compile , the program would not run , or I would get the same nothing happening as I do with the original function.
Many Thanks