Hi guys, I've just got a few basic questions here for you.
I'm currently working with Linked Lists in C (just starting out) and just came from Java.
First off, I have a file list.c which contains all of the functions that let me add a new node to a list and remove them, prepend, append, etc. Also, I have the list.h file which contains the function prototypes.
My question is, I want to make a function in another .c file which returns a linked list that I create inside the function. So for example if I have:
1 2 3 4 5 6 7 8 9 10
|
struct newFunction() {
struct node{
int x;
int y;
char name[20]; //store a string
struct node * next;
}
//rest of code here
}
|
Is this how I would go about returning a linked list from a function. I apologize for my arrogance, I'm just having a hard time getting started.
Also, I want my nodes to be able to store two integers and a string. Is how I declared the list above how I would go about doing that. And then when I added the data to the nodes I would just use my function from the list.c file new_node(1,1,"Hello"); for example?
Thanks for all the help. Sorry if I'm way off track here, I'm just finding it hard to jump onto this mystical creature that is C coming straight from Java.