Passing global pointer to function

jgabb

I declare a global struct Word *root = NULL; which I populate by using some pthread calls(created a BST) and when I go to print out an inorder traversal function by calling inorder(Word *root), it gives me an error saying "unexpected type name 'Word': expected expression". I don't understand what am I doing wrong.

void ordered(Word *root); // declaring function
//code//
Word *root = NULL; // declare global pointer to root

/*Main*/
//code that does some work and eventually creates a BST with root

ordered(Word *root); //call to my function
barak manos

Follow these rules:

  • You must specify the variable type when you declare the function
  • You may specify the variable name when you declare the function
  • You must not specify the variable type when you call the function

In your example, the variable type is Word* and the variable name is root.

So change this:

ordered(Word *root); //call to my function

To this:

ordered(root); //call to my function

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related