I can't run C++ code

I Can't Run Program Error message :

enter image description here

Here's the code:

#include <iostream> using namespace std; int main() { cout << "C++"; return 0; } 

1 Answer

First install the compilers if you already have not.

sudo apt install build-essential 

Compile the program with g++ /path/to/filename.cpp -o /path/to/output (note that gcc may not work with programs written in C++. You would need g++).

Then run the program with /path/to/output.


Your code worked for me. I saved your code in the file new.cpp, and compiled it to an executable named output.

[archisman@home-pc ~]$ g++ new.cpp -o output [archisman@home-pc ~]$ ./output C++ 

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

You Might Also Like