How do I run a file using .replit
So I have a
.replit file and it looks like this:
Now I also have a
main.cpp file. So I was wondering, is there a way in which I can run the
main.cpp file using the
run thingy? For example can I do something like this:
Or is that just not how things work...?
.replit file runs a bash command, like Codemonkey51 said. It's effectively a command for a Linux terminal (in this case, Ubuntu.)
If you want to run multiple commands at once, make a
.bash file and set the command in the
.replit file to run the file (i.e.
A very basic example of what to write in the bash file could be this:
Line 1 compiles all the .cpp files in your base directory (if you want to include all files 1 folder deep, try replacing
*.cpp */*.cpp, might be a better way of accomplishing this but I'm not sure) using the c++2a standard (which is the newest version of C++, you could use c++17 or c++14 etc instead)
Line 2 makes the
main compiled program accessible
Line 3 executes the compiled program
I would honestly suggest excluding the
.replit file altogether unless absolutely necessary until you understand bash at least a little bit. It's not super complex, though, and overall I think it's worth it to learn, especially if you plan on using replit a lot.