-1

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.

3
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.

  • I get the error 'Permission denied', when I use 'main.o'. – V.I.L Jul 4 '18 at 7:57
  • I updated gcc command and renamed output file to main – Eugen M Jul 4 '18 at 8:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.