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

Why your Disk Utility is showing wrong used storage space on Mac?

Hello, Friends today we will be talking about the most common problems on MacBooks these days. As I remember , last week I was so upset that my disk Utility was showing the size of Apps as 103 Gigs even when the used storage was just 38 gigs . I searched the internet and found out this solution and decided to share it. All we have to do is to rebuild the index of spotlight. To do so follow these steps: First of all, open spotlight , then type, Hit enter, Now, click on  spotlight and click on the Tab Privacy Now, click the '+' button and add Your whole hard drive to it. In this case it is Macintosh HD Once you restrict spotlight's access, just select the drive and click the '-' button and exit. After exiting spotlight will rebuild index and your disk utility will show correct size of the drive and all. Thanks for reading. keep coming for more. Don't forget to share and like ;). Vide...

Quadratic Equations: Made Easier for JEE

Quadratic Equation lesson 2 In the previous lesson we learned on how to solve an equation. We found three methods to solve the equation. If not visit  http://scipsycho.blogspot.in/2016/08/quadratic-equations.html Now, we will go into details about quadratic equation, the importance of parameter a, b and c and other things that are important for JEE aspirants. Let's begin. As we saw earlier, a quadratic equation can be represented by  ax 2  + bx +c =0.  Let's start with 'a'. 1.) Coefficient of x 2  Case 1. : when a < 0 let's inspect the graphical form of the equation. If x -> ∞, only the  x 2   term will decide the outcome of the expression as it's magnitude will overwhelm the other factors. Now, as  x -> ∞ the value of expression will tend to infinity if a>0. However, a is less than zero therefore, the expression will tend to  -∞. when x -> - ∞,  x 2  -> ∞, and thus even then the expres...