-1

I tried to run a c++ file with the mac terminal, but it gave me the error as shown below:

enter image description here

Does anyone have any idea why this is happening?

timg
  • 381
  • 2
  • 13
  • 2
    Where did the `test` file come from? Last I checked, GCC names the output `a.out` by default. – chris Aug 05 '20 at 00:15
  • I did "ls" in the terminal and saw a file titled "test'. I thought it was the result of doing "g++-10 test.cpp", but it turns out to be another file with the same name, not related to test.cpp – timg Aug 05 '20 at 17:19

1 Answers1

0

If you do this gcc test.cpp you will get executable called a.out, and to run it you type:

./a.out

to get executable called test you have to run g++ test.cpp -o test now you can run this:

./test
  • ah I see. Is the default name always a? Also, what happens if there is already an "a.out" in the directory your in? Will that one be replaced? – timg Aug 05 '20 at 17:18
  • @timg yes it will be replaced –  Aug 05 '20 at 17:19