10

I'm trying to run some C++ code in Visual Studio 2015. When I build it I get no errors, but once I run it, all I get is an empty console. I don't think it froze, because I can see a flashing underscore. Also if I run it in debug mode Visual Studio just freezes.

I used a simple "hello world" code:

#include <iostream>
int main()
{
    std::cout << "hello world!\n";
    return 0;
}

What I tried:

I tried reinstalling Visual Studio, but it didn't fix anything. I also tried running some Python and C# code and both worked without problems.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MatijaxD
  • 171
  • 2
  • 8

1 Answers1

22

Note: this issue is also being reported by gcc/mingw/cygwin users.

Do you use Avast antivirus? If so, try disabling it and then test your program. There have been several similar questions on SO recently and Avast was the problem.

If that fixes the problem I suggest you add an exclusion for your "\Visual Studio 2015\Projects" directory instead of completely disabling your antivirus. You could also file a bug report with Avast or try a different antivirus.

Blastfurnace
  • 18,411
  • 56
  • 55
  • 70
  • I have been using this as a dupe target as we are getting more and more of these questions posted. Would you mind generalizing the answer for people who are not using MSVS? – NathanOliver Feb 26 '16 at 16:42
  • @NathanOliver - I really wish you would not have used this as a dupe link for the question _[here](http://stackoverflow.com/questions/34341839/blank-console-window-when-running-program-from-codeblocks)_. Code::Blocks has an entirely different reason (unrelated to Avast) that causes the console to appear or not appear, and people who are asking are mis-directed here, where the focus is on a visual studios/Avast related answer. – ryyker Feb 17 '17 at 17:55
  • @NathanOliver - sorry, was still editing. I would like to post an answer on the other question, but it is closed. I recently spent some time search for why my Code::Blocks environment always displayed an empty console popup. It is a simple setting, but not so easy to find if new to the environment. – ryyker Feb 17 '17 at 17:58
  • @ryyker Well Sorry you feel this way but this was the exact issue the OP had. – NathanOliver Feb 17 '17 at 17:59
  • @NathanOliver - Not arguing that, and please don't take it wrong. I see the relevance of your answer here, but it does not address other, more common reasons for console popups in the _Code::Blocks_ environments. – ryyker Feb 17 '17 at 18:08