How do I run code in the terminal on a MacBook?

This is probably a dumb question but I am new to Mac and I'm trying to figure out how to run a .cpp file in the terminal window to check for user input in my code.
You can compile a file named 'foo.cpp' in the current directory into a program named 'prog' with the following command
clang++ -std=c++14 -Wall -Wextra -pedantic-errors foo.cpp -o prog
Then you would run the compiled program by typing its name as a path
./prog
Topic archived. No new replies allowed.