0

I installed Visual Studio 2013 on my Windows 10 machine. To test the installation I wrote a simple program in C++:

#include <iostream>
using namespace std;

int main(){

    cout << "Size of char is: " << sizeof(char);

    cin.get();

    return 0;
}

It's embarrassing to post such a simple code here but the problem is as follows. The build process runs without errors or warnings. But when I start the program via Debug-Button, Visual Studio freezes. I also tried starting the .exe in cmd. The result is a blinking cursor in an empty line with no further reaction from the console. Can somebody tell me what's wrong? The Project Type in Visual Studio is empty visual c++ project.

Raistlin
  • 997
  • 2
  • 11
  • 33
  • 2
    Add " << endl" in your code - use cout << "Size of char is: " << sizeof(char) << endl; – Dmitriy Dec 02 '15 at 22:55
  • 4
    The usual question. Are you running Avast? This is a well known issue with VS. See http://stackoverflow.com/questions/33718236/visual-studio-2015-build-successful-but-debugging-never-stops-loading – Peter M Dec 02 '15 at 23:01
  • The main idea of this problem connected with buffer flushing. Try "flush" method or << endl; Hope it's connected with this. – Dmitriy Dec 02 '15 at 23:03
  • 1
    `cout` will not flush, write data to the console, until it's buffer is full, it is instructed to do so, or the program exits. You've written too little data to fill the buffer, have not asked `cout` to flush, and `cin.get()` will block program exit until enter is pressed. @Dmitriy 's suggestion to add `endl` will force a flush. – user4581301 Dec 02 '15 at 23:04
  • 3
    @Dmitriy as `cin` is tied to `cout`, the flush is not needed (more [here](http://stackoverflow.com/a/9275346/3723423)). An installation problem or a third party software problem is more probable here. – Christophe Dec 03 '15 at 00:11
  • @Chrisophe, thanks, didn't know about this. – Dmitriy Dec 03 '15 at 00:21
  • Thanks to all of you. I indeed were running Avast. I deactivated it and magic was happening! The program started. I indeed were not aware of the VS/Avast issue. – Raistlin Dec 03 '15 at 07:49
  • You mean to tell me that Avast sees the above code as something to block!? If so, then wow... That is some restrictive heuristics right there :) Or is it more a case of Avast not playing nice with VS debugger or something? I also was not aware of this issue before... Good to know. – Richard Tyregrim Dec 03 '15 at 08:19
  • @Richard: It seems that indeed Avast is not a good friend of Visual Studio. I found out that there are plenty of VS-Users that ran into that problem. – Raistlin Dec 03 '15 at 17:57

1 Answers1

0

Finally it works. As Peter M mentioned in his comment, the VS/Avast issue was the problem.

Raistlin
  • 997
  • 2
  • 11
  • 33