How to add a main function without running into duplicate main errors

Hi, Sometimes, I need to run some code for debugging purposes, But if I try to add a main function to my cpp file, the compiler understandibly complains about duplicate main symbols.
Is there a way to run my executable with all the relevant compiler flags ?

1 Like

I would add a new file with the main function and link in the exercism file(s) required. It has been like 25years since I wrote C++ last time, so I cannot go into any details :slight_smile:

1 Like

What is your intention here? Do you want to print some debug information?

simple cout debugging.

You can use cout in the cpp file for the functions that are called, to see them during testing. Same for the online editor.

If you need something specific, you can also build your own main function and include the headers you want to use the included functions.