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

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

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

Thinking Out of The Box

Time Machine Paradox - .. -- . / - .-. .- ...- . .-.. / .. ... / .--. --- ... ... .. -... .-.. . .-.-.- Last Night , I was thinking that if it was really possible to make a time machine or not. I also read a lot about time conspiracy theories that do exists (the so called "Urban Legends"). Almost all of them were completely fraudulent but still there was just one argument that flipped over entire conspiracy theories i.e. Where is the time machine ?... Now, I was forced into thinking that if it was really possible ( the philosophical way). And in the end I came to a very seemingly great conclusion i.e.  We can make a time machine in just 60 seconds or so but we will need a few things listed below. 1. ) A thing where we can write the correct time ( i.e. 60 seconds from now ) and the geographical coordinates of the place so that the data written would be easily be accessible even after 100 years or so. 2.) We need a man who never gives up. So...