The code snippet:

#include <iostream> using namespace std; int main(){ unsigned int a, b, diff; cin>>a>>b; diff = a - b; if(diff % 10 == 9){ diff--; }else{ diff++; } cout<<diff; return 0; } 

The command used to compile:

g++ -Wall -Wextra -Werror -c main.cpp -o main.o 

The error:

bash: ./main: No such file or directory 

Error when 'main.o' is used:

bash: ./main.o: Permission denied 

I am using Ubuntu 16.04 LTS.

0

1 Answer

g++ -Wall -Wextra -Werror main.cpp -o main 

Don't use the -c flag if you want to create an executable.

 ./main 

If you press Tab it will autocomplete.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy