Undefined reference to main even though i did everything

Help, I’ve been trying to do the sorting hat quiz thing and I did everything it asked for until they wanted me to compile and execute to check for bugs. When I tried to do so, I got this ;


I did everything I could and rewrote the whole thing over and over trying to check if I made any typing mistakes or if I forgot to add anything important. I did everything the instructions asked for. What did I do wrong? It’s 10pm and I’m crying myself to sleep.

1 Like

I am not an expert on c++ but examples of a main function always seem to end in return 0;
Here is a explanation on the subject.

int main () {
   // your code
   return 0;
}

Hope it helps.

Thank you ! I tried it but it didn’t work. The same problem remains :frowning:

I’m not actually taking the c++ course at this time, but I have worked through tutorials in the past. I went to the project you are working on, and initially got the same error. However, after clicking the ‘save’ button at the bottom of the code editor, and then running the g++ sortinghat.cpp it worked fine. Is it possible that you didn’t click ‘save’?

I tried it and I guess that was the reason why - it worked!
Thank you so much for solving my misery ;-; You’re the best!

great question and good looking out! i added the press Save part to the instructions

2 Likes