how do I open the console like this - c++

I learn programming in codecademy, and they have a simulator with the console on the right side like this.
When I want to compile and run programs, I type g++ mycpp anothercpp then run in with second command ./a.out
Can I open this console in the actual c++?

You need to install a compiler. You seem to be using Windows. On Windows, it's easy to install clang compiler. Once you do it, you'll be able to do something similar:

Related

Using g++ and ./a.out

Hello everyone I have finally decided to learn to code, even if it is just a hobby, I once picked it up years ago and I am gong through the tutorials on codeacademy, I have a question for everyone.
Tonight I downloaded Codeblocks with Ming compiler, the programs work fine, the ones I have tried to rewrite from memory from my lessons, but I am missing something that became second nature during my lessongs. After writing the code required for the challenge, I would go into a folder with the extension .cpp and add the command g++ temperature.cpp(for example) -o temperature and then once the a.out file was created I would go into that and do the ./temperature command to execute the program.
I like being able to manually compile and than executre my code, and would like to be able to do this in codeblocks. I know it may sound stupid, and I know Codeblocks does it for me, but is there any way, I can do it for myself? Is there any way I can write my code and have the terminal on the right side of the screen like codeacademy has it?
Or should I just forgot about the g++ and ./ commands? I figure that I can do it throug the command prompt but that would require getting to the folder etc, and have not yet fully familiarized myself with the command prompt.
Thank you in advance for the help.
I first commented, then I decided to make it a full answer, since I kind of answered the heart of the question in the comments by accident anyway.
Yes, you can absolutely do this yourself. Using an IDE (Integrated Development Environment) like Codeblocks will make things easier for you, but there is no harm in learning how to do it under the hood if that interests you--especially if you're doing this for a hobby and not a work situation with time constraints.
To understand what g++ is fully capable of, I recommend consulting the official documentation. That will explain how to properly use it better than me and probably anyone else could.
While you're at it, I would also recommend learning how to use make if your platform supports it. It is a tool that can make compiling easier than working with the compiler directly, but offers more control than your IDE might (though this depends on the IDE).
You mentioned that you used the Ming compiler for Codeblocks, so I'm assuming that you're on Windows. To use the g++ command here, you'll have to
Add it to path, in order to make the g++ commands available for you throughout the system. This video explains adding the ming compiler to the path pretty well.
Call the command (from the command prompt, or some other kind of terminal)
You will have to get just the basic commands down for the command prompt, but it's not that daunting. cd to change directory and dir to list directory, and navigate to your project directory in codeblocks.
Finally, keep in mind that because you're on windows, when you compile with g++ you'll get an .exe file. .out files are produced when you compile on linux. If you want to get a linux shell on windows, I'd recommend looking into either Cygwin or WSL.
IDEs make compiling and executing much more convenient, but it's not a bad idea to learn how it all works through the command line. Best of luck!

Glitchy font when running start command from ConEmu

Before I start...
my tool chain consist of MinGW, ConEmu, and Vim to make C++ programs.
I wanted to test to see if MinGW was working by seeing if g++ was setup correctly on my system PATH, and it turned it was because I successfully compiled a simple console program that outputted the text I provided to standard out. However, I came across this...
When I do the command start test.exe from window's cmd shell in ConEmu (I use the start command because I want it in its own standalone prompt), the text looks like this.
These little white lines are annoying and I would like to know what's causing it...
When I run the standalone from the explorer it looks completely normal.
Is there something in ConEmu's settings that's causing this that anybody is aware of ?
I found a work around. I just end up using the program called cmder. Which is practically ConEmu but with more features built on top of it.

Use of terminal and compiler in geany for windows7

How can we integrate a terminal and compiler to geany message window in windows7 so that i can excute the c++ program ?
I'll be very quick on this one because that's a question that gets asked a lot here.
First, you need to install the compiler (gcc and g++), then, you need to edit the %PATH% environment variable of Windows 7. Just add the directory where the gcc.exe and g++.exe are located. And, voilĂ .
Here's yet another related question: Geany compiling
For your terminal question, I don't know if the VTE plugin is available for windows. You should definitely use that instead of the windows cmd...
Usually, executing a program is done by pressing F5.

running unix like command "./a.out <data.txt" in windows environment on c++ file

How do I run a command like interface on windows and use the g++ and ./a.out
I am a beginning programmer used to using putty/ssh to write (nano), compile (g++ command), and run (./a.out) c++ programs.
Our class has now switched to netbeans, but our latest assignment requires us to use the ./a.out <datafile.txt-like command.
Or is the input redirection style ./a.out <data.txt unique to unix and cannot be done in windows?
edit: the < input redirection marks made my post mostly unreadable. Sorry about that
2nd edit: There is actually a terminal built into netbeans that VERY conveniently starts in your project directory. open it in netbeans by selecting Window -> output -> Terminal
Cygwin is a collection of tools which provide a Linux look and feel environment for Windows.
start,
run,
cmd,
cd directory,
g++ a.cpp,
a.exe
Windows includes . in $PATH, so the ./ at the beginning is superfluous (and wrong, since it would be .\). The rest is the same.

How do you run programs through TextWrangler?

I have just started to get experiment with C++ on my MacBook Pro, and am very new to it all. Through research, a few different people have suggested to use TextWrangler for writing the code. I have put together some of the code that the beginning of a tutorial has given me, but I am now unsure how to run it through TextWrangler. I know that you are supposed to compile it first, but that is mostly where I'm stuck. I have downloaded Xcode so I have gcc, but I don't know where to go from there. And after I have compiled it, is there a simple way to run the file? Like I said, I am very new to all of this and may be looking at it in the wrong way.
TextWrangler is only a text editor, you still need a compiler to compile your code and then you need to run your code.
Xcode (which is an IDE) does all that for you so the confusion is understandable.
for now opening a terminal and doing g++ filename.cpp to compile and ./a.out to run your program will get you going. But you really have to learn to use a IDE or how to write a makefile.