cant get main to call functions, unsure of parameters. c++
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
cant get main to call functions, unsure of parameters. c++
seems like a simple problem to call the functions in my program but i can't figure out the parameters to use. i believe it has to deal with using new nodes and pointers. problem lies in the main function, trying to create the avl tree with the dictionary
void go_through(FILE *f,NODE_AVL *a)
{
if (a == NULL) return;
/*here insert the operation for each element;
(Example: for saving the AVL into dictionary write here
fprintf(f,"%s",a->info) where f is the file);
*/
if (!a->isdeleted) fprintf(f,"%s",a->info);
go_through(f,a->left);
go_through(f,a->right);
}
void menu()
{
cout<<"\t\t***************************\n";
cout<<"\t\t\t== MENU ==\n"
<<"\t\t***************************\n"
<< "\nHere are your choices:\n"
<< "\n P: Print the whole dictionary.\n"
<< " A: Add a word into the dictionary.\n"
<< " D: Delete a word from the dictionary.\n"
<< " N: Count how many words contained in the dictionary.\n"
<< " C: Check spelling of a text file provided by the user.\n"
<< " Q: Exit the program.\n";
}
I may be wrong, I've not done anything with C in 3 years, but don't functions have to be defined BEFORE you can call them? ie. the main function always goes at the end of the program.
From what I have understood from your code the main should be written like this
Let me explain what I have done line by line:-
1.Create a pointer of type NODE_AVL i.e, AVL root_avl;
2.ALlocate memory to it [ malloc does that even new does that but, I haven't ever used "new" ]
3.Then passing it as parameter to create_AVL_from_file
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.