Search code examples
c++macosterminalpermission-denied

g++ permission denied(Mac)


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?


Solution

  • 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