Skip to content
← Back to Community
My C++
Profile icon
EhanireOghogho

Why is it that my code gives me an error whenever I add a new file to a Repl I created

Voters
Profile icon
EhanireOghogho
Comments
hotnewtop
Profile icon
Coder100

Hi, replit tries to compile both of the files into the same cpp file, so you have to configure the run button:
https://docs.replit.com/programming-ide/configuring-run-button#configuring-the-run-button

Here is the code you could add in your .replit file:

run = "g++ main.cpp ; ./a.out"

And then to run the other file:

run = "g++ 'how to accept user input.cpp' ; ./a.out"
Profile icon
juliusgunnars12

[Simple Solution]: Change the main to something else, it worked for me. There are two main() change one of their names to main2() or something...

Profile icon
EhanireOghogho

thank you, it's working now
@juliusgunnars12