Skip to main content
 

Creating and running C++ file

1 min read

Hello this is a video for which I already did, but a video always explains it better.

https://www.youtube.com/watch?v=Quf9Cmk9HgI

 

Create and run C++ file

2 min read

Although sometimes it seems a bit complex, it's actually very easy to compile and run a program, let's go step by step.

On the first screenshot we can see the directory we need to follow on cygwin, it's not the same for every folder, that means you need to change it to wherever your source code is saved.

It always needs to start with cd /cygdrive/...... and then as you can see mine has a few directions.

Also to type in a basic program your code must start with

<iostream>

using namespace std;

int main()

and you start typing your code

I just typed in a "Hello from Mexico with Love" as an example, once your done with your code you need to save like this "whatevernameyouwant.cpp" be sure to type in the .cpp so that the compiler (cygwin) can know that we have a C++ file.

Then to compile it on cygwin you type the g++ command and the name of your program with .cpp at the end.

After that you type in an "ls" command to check your programs on that folder.

And to finish you just need to run in with ./a.exe

The screenshot shows every command, I hope it helps.