I'm currently wrapping up an assignment for class and i've been able to figure out most of the curveballs the professor threw at me but i've hit this one and it just seems strange. It seems he's declared... a pointer that is also a function?

struct data_node {
   char name [25];
   int data;
   struct data_node *next;
   };

struct data_node *find_node (struct data_node *linkedListPointer, int num);

how would I go about using this pointer that is also a function? Do I just fill it out with what I want? Thank you for any advice and assistance in advance!

>It seems he's declared... a pointer that is also a function?
Nope, it's a function that returns a pointer. The closest thing to a pointer that's also a function would be a pointer to a function:

void (*fp) ( void );

Did you say that double sqrt(double x); is a double that is also a function? It's a prototype of a function named sqrt returning double value!

So you have a prototype (declaration) of a function named find_node with two parameters. It returns a pointer to (found) structure (probably, a node of a list). Example:

struct data_node* listroot;
struct data_node* found;
...
found = find_node(listroot,2009);
if (found == NULL) { /* not found */
    ...

You must declare all names before use them. You must include function prototype before call it.

Look at http://www.tenouk.com/Module4.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.