Skip to main content

How to run C++ program directly from compiler?

Today, we will be learning on how to run a C++ program directly from compiler.So let's start.

Hit cmd + space and type terminal,
Spotlight-opening terminal












Now, hit enter.

I will be running a simple hello world program named hello.cpp placed on my desktop.
So, first of all change the directory to Desktop.
Terminal- cd Desktop



Now, type g++ <filename.cpp> -o <filename>
and hit enter
Terminal - g++ <filename.cpp> -o <filename>




If the file is with no errors, it will do nothing otherwise give you details about the error.
Now, type ./<filename> like this and your program will run in the same terminal window.
Terminal - ./<filename>





Otherwise you can check the current directory and find a file named <filename.exec>. Hit enter to run directly.
<filename> unix executable file











Thank you for reading. Keep coming for more. Don't forget to like and share ;). Videos in progress. 

Comments

Popular posts from this blog

How to install windows using Bootcamp on macbook pro?

Hello friends, today we will be discussing methods on how to install windows using Bootcamp on macbook pro? Well, for productivity there is no rival worthy to compete with MacBook Pro. However, for us gamers windows is very vital. So, Intel -Based macs can install windows in a Dual Boot Method with Bootcamp. First of all, you will need a Macbook pro (obviously) and a windows 8.1 or above iso file  https://www.microsoft.com/en-in/software-download/windows8ISO I insist that you install a genuine Windows 8.1 or above as it will create problems afterwards. Also it is important to do a compatibility check before you decide to install windows on your Macbook Pro . My MBP requires Windows 8.1 or above. For more info about compatibility visit  https://support.apple.com/en-in/HT204048 I also insist that you backup your Macbook Pro before any change you want to make. I will not be responsible for any Data Loss! Now, let us begin St...

Quadratic Equations

A Quadratic Equation is an polynomial equation with highest degree 2. For e.g.: 5x 2  + 2=0 2x 2  + x + 1=0 General form of the equation is: ax 2  + bx + cx = 0 where a is not equal to 0 Normal form of Quadratic equation can also be represented by two parameters. (say m and n) x 2  + mx + n = 0 Normally , We are asked to find the roots  of the equation. The roots of the equation can be  found using three methods. Let us take the example x 2 -6x + 8=0 and solve this equation using these methods separately. Let's Start: 1.) The Grouping Method or that's what i call it    In this method we try to split the middle term or 'b' such that it is equal to the product of the rest of the terms or 'ac'. Now, let us apply this method on the above equation. x 2  -6x + 8=0 As, it is easily visible, the term -6 has to be split in a such a way that it's product equals to 8. x 2  -6x + 8=0...