Sorry if I'm being dense, but I can't find the console for Visual Studio. I'm in the subsystem:windows mode because I'm writing an app that requires me to be in this mode. Is there a different method of debugging that doesnt use the console? I have some print statements in my C++ program but I can't find where they are printed, can anyone help me find it?
You can either use an external terminal, ex. xterm, but I think this guide will help you to open and use an integrated terminal in Vscode:
https://code.visualstudio.com/docs/terminal/basics
Your print statements are currently just lost - you have chosen not to have a console, since you're in a Windows susbsystem.
There's OutputDebugString, which does write to the Visual Studio "Output" tab. But it won't format the output for you. You can do some std::streambuf magic to make std::cout forward to OutputDebugString, so you get std::ostream formatting.
Related
Whenever I ask for the user input (using C or C++), VS Code will open my windows terminal, ask for input, and then close and ask for the same input in the integrated VSC terminal.
Now, this should be a very simple fix but no matter what I google, I can't find anyone having the same issue.
Also, when I enter input into the windows terminal, it doesn't use that information at all. It just closes after all of the console input operations are complete. Only the VS Code's integrated terminal does anything useful.
Anyways, does anyone know how I can disable my windows terminal from opening up when running C/C++ programs?
Tried googling for help but couldn't find anything directly related to what I was experiencing
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..
I am currently writing a toy-compiler in my free-time in C++ and I am using Visual Studio do to my development work. Although I am on a Windows System, I have replaced my standard Console with the msysgit bash version. Now, I am trying to implement color-coded error messages which work fine in bash, but don't work in cmd. I am coloring my text using the bash color keys like \x1B[0m etc... Now, the problem is that when the compiler outputs error messages to the console, someone using cmd.exe as their default console will see a garbled mess of seemingly random letters making the error message hard to decipher. One solution I found to be working is completely disabeling color coding on Windows systems which works, but is kind of inconvinient. I am looking for a way to find out whether the console to which the compiler is outputting to is cmd.exe or bash.exe. I have looked through MSDN and didn't find anything particulary useful.
I've been searching arround StackOverflow but seems I can't find the exact explanation for my problem:
I am running a GUI Application compiled under Visual Studio 2012. As it is a GUI application, sometimes it's quite hard to Debug it normally, so I need to printout some values while executing. I've done a couple of printf but the problem is that, as it is a GUI application there is no Console available while debugging it. I need to debug and have a Console to display these output values from printf. I know under CodeBlocks it is possible to do so, however the project is quite big to have to migrate everything to gcc CodeBlocks.
Could anyone tell me how to display such console or how to workaround the problem and have a similar result?
Thank you very much
Windows applicaton can't be both GUI and console.
There is a workaround however:
If you applicatop is based on MFC use TRACE macro.
Otherwise make your own wrapper around OutputDebugString function.
Both will output to Visual Studio's 'Output' pane when you launch our program under debugger
An of course you can always output diagnostic messages to good old log file.
Can anyone tell me please how to extract the data from a .reg file into the registry?
I've tried:
system("regedit /s product.reg");
It doesn't work, I have also looked at various other questions on here but have had no joy and I have also trouble understanding them.
Can anyone shed any light or send me a link that has a good example please?
Thanks
The following things applies to Windows Vista / Windows 7 and later version.
You won't be able to successfully execute regedit.exe unless your application is not running with Administrator privilege.
If you're using Visual Studio 2005/2008/2010, go to the property window of your project, expand the 'Linker' options, and select 'Manifest File'. Change UAC Execution Level to 'requireAministrator'. Save your project and rebuild your project.
According to this, the correct command is:
reg IMPORT <FileName>
system("product.reg")
should also work. This is akin to double-clicking the file.
Since you're on Windows anyway: ShellExecuteA("product.reg"). Unlike system, this won't start a console window.