Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

c++ - How to open the cmd console inside Visual Studio Community for outputs while on debugger mode?

I'm recently learning how to use Visual Studio Community.

When i start the debugger, a cmd console with the output of my .cpp opens on another window, but i want it to open inside the Visual Studio as a window, like the developer powershell window.

Can anyone help me out with this one?

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are two methods to meet your needs.

  1. I suggest you to download a VS extension named Open Command Line. The Open Command Line extension supports all types of consoles like cmd, PowerShell, Bash and more. You can easily configure which to use by setting the paths and arguments in the Options.

  2. You could add the following code in your PowerShell_profile.ps1. You could refer to this link for more information.

Visual Studio2015:

pushd 'C:Program Files (x86)Microsoft Visual Studio 14.0Common7Tools'    
cmd /c "vsvars32.bat&set" |
foreach {
  if ($_ -match "=") {
    $v = $_.split("="); set-item -force -path "ENV:$($v[0])"  -value "$($v[1])"
  }
}
popd
write-host "`nVisual Studio 2015 Command Prompt variables set." -ForegroundColor Yellow

Visual Studio2017:

pushd "C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
  if ($_ -match "=") {
    $v = $_.split("="); set-item -force -path "ENV:$($v[0])"  -value "$($v[1])"
  }
}
popd
Write-Host "`nVisual Studio 2017 Command Prompt variables set." -ForegroundColor Yellow

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...