How to clear screen use Eclipse IDE - c++

How to use system clear screen in Eclipse IDE. I use Visual Studio 2017 with command system("cls").
I tried system("clear") but cannot.
system("cls") or system("clear");
'clear' is not recognized as an internal or external command,
operable program or batch file.

system() calls another executable which is provided by your current operating system or a command that's recognized by your default (terminal) shell.
It has nothing to do with your IDE.
There's no generally portable way to clear the screen using c++.
The closest portable way you can get is using something like ncurses.

Related

I want to use run my CLion programs in a Terminal window

Is there any way I can execute my programs in Terminal window on CLion on Mac like with say Visual Studio on Windows?
I don't understand. Why can't you simply:
open a terminal window
change the directory to the folder where CLion outputs the .exe file
run the .exe
That should be the general OS-agnostic process.
What part of it is stumping you on a Mac? We all want to help but you may have to give us more info before we can understand what you really need to know.

gnuplot command not working with system() function in C++

My gnuplot command is not working in my C++ program. I am trying to run gnuplot command in C++ program like this:
system("gnuplot");
It gives the error:
'gnuplot' is not recognized as an internal or external command. etc.
when I try to run gnuplot in cmd, it works fine.
Any one have idea that why gnuplot command in not working with system() function in C++?
The reason is probably that the environment you execute your C++ program in doesn't tell your operating system to look in the right places to find your gnuplot executable.
Try the full path to the GNU Plot executable, include the file suffix (.exe) if you're on Windows, or make sure to set the PATH environment variable to include the directory in which your gnuplot executable is.
Check whether the path to the gnuplot is in your PATH environment variable. Or alternatively, you can use the absolut path to it when calling system()
Thanks you for answers friends,
I found the solution finally: After editing the environment variable $path, one has to restart the visual studio to get the latest value of environment variable. When I restarted my visual studio, it works.
So when ever you change your any environment variable, just restart visual studio (in case you are using it).
Thanks and kind regards,
Awais

How to display standard output in Visual Studio 2015?

Most IDE's I've seen (NetBeans, QtCreator, XCode, CodeBlocks, Eclipse) provide an out-of-the-box method to view standard output either in one of its embedded window or external console or in a log BUT Visual Studio.
I really don't want to allocate a separate console as it is suggested at THIS question. I'd also prefer not to redirect it to a file as it is suggested at THIS question (output file is not created with the suggested console command (2>output.txt)). Please don't give answers that modify the codebase like using OutputDebugString.
If displaying standard output inside VS this way is not possible, a working solution of the other two alternatives would still be welcomed, namely using external console (which I tried using without seeing the output in it) or a log file.
If it is only for debugging purposes, you might find Debug Breakpoints/Tracepoint actions helpful.
They enable to log custom strings with expressions (i.e. variables) to the visual studio console.
For a non-console windows application, by default (i.e. without changing your codebase, as you are requesting) all output to stdout is lost..

How do I compile and run a C++ program from Vim?

Whenever I use the :!make % command, vim returns "make is not recognized as an internal or external command, operable program, or batch file." I have tried set makrprg=\"C:\\Program\ Files\ (x86)\\Microsoft\ Visual\ Studio\ 14.0\\VC\\bin\\cl.exe\". However, the same message appears. I believe the error may be in the path I have set, or the format of my statement; however, I am not sure if there is any other underlying cause.
I would greatly appreciate any input. Thanks in advance!
FYI:
I use a Windows 8 computer, and the compiler I typically use is the Microsoft Visual Studio 14.0 compiler.
! is a VIM command that invokes the shell. !make tells the shell to run whatever the shell can fund under the name make. If you want to use VIM's makeprg, you need to use the VIM command :make.
Having said that, setting makeprg to sonething that is not a real make-style program is probably going to work only in the very simplest scenario.
You can run the compiler directly with !cl %. You need to put cl.exe in your PATH and probably set up other environment so that cl can find libraries and include files.
This is because you do not have the make executable installed, which is what vim is looking for. If you're looking to compile on the command line with make, I would recommend switching from the Visual Studio compiler to MinGW
make is a Unix tool, and while it is also available for Windows (in various flavors, native, Cygwin, or MinGW), it is usually not what you will be using together with MS Visual Studio.
It is difficult to be specific, since you told us nothing about the project you are trying to compile, but I will try.
If your project is set up as a Visual Studio solution, you can compile it using devenv:
devenv /build release mysolution.sln
devenv /build release /project mysolution/myproject/myproject.vcxproj
Your project might also be set up for NMake (which is a make-like tool shipping with MSVC):
nmake [target]
The two commands above require the current shell to be properly set up, which can be achieved by starting a "Visual Studio Command Line" from the start menu, or running %VS120COMNTOOLS%\..\..\VC\vcvarsall.bat from whatever shell you happen to work from. (Adjust VS120COMNTOOLS to whatever version of MSVC you are using.)
Or your project might actually be set up using "real" makefiles, in which case I second Levi: It seems like make is not installed, or has not been added to your PATH environment variable.
make [target]

Show command prompt with Qt Creator and CMake

The dev environment in question consists of:
Windows 7
MinGW (g++)
CMake
Qt Creator
The problem is that Qt Creator, a lovely IDE as far as I can tell, does not display programs' command-line output. It seems to have its own proprietary debug pane, but it doesn't give me, for example, runtime errors. It just tells me that the program has failed and gives me the exit code. I'm using Creator only for its C++ capabilities, and not using Qt in any way, so the proprietary pane is useless to me.
So I ask this: Can something be done? Am I missing something really, stupidly obvious like a built-in command line? Or, if not, can I at least use some filthy and/or repulsive hack to get it to display the Windows command prompt upon running a program?
Last thing; I did do some research, and found a way to edit the Qt project file to display the prompt, but... I'm using CMake, not Qt projects. So that doesn't answer my question. If I can do something similar with CMakeLists.txt, that would be wonderful. But Google has failed me on that front, so I'm not holding out too much hope.
EDIT:
I'm specifically worried about runtime errors. cout and printf are rerouted to Qt Creator's window, so that's fine. I don't get runtime errors unless the debugger catches them, and the frequency of that is less than ideal.
Windows GUI programs don't have standard output.
In Windows there are two possible entry points in the standard runtime. The console one and the windows one. The console one will inherit console window from parent process or create a new one and connect the standard input/output/error streams to it, while the windows one will leave them unconnected unless they were explicitly redirected by the invoking process. A Qt application is (probably; you could have console Qt-Core application) a GUI application and Qt Creator (nor any other Windows IDE) does not redirect the output explicitly. Therefore the standard output is not open at all and the writes are being discarded.
However windows have separate logging facility for debugging purpose. This is what you see in the debug window. You can write to it using the native OutputDebugString API. I am sure you can also direct the Qt debug log there.
Note, that when it tells you the program has exited with status 0, it means the program ran, which in turn means it compiled successfully and thus there were no errors from g++. There may have been warnings, in which case you should see them in the appropriate other window. Compiler and program output are different things; the IDE does read the compiler output.