1

I have downloaded Code:Blocks with MinGW, trying to get some C++ going. After installing, opening, and creating a console application, I have been unable to run the "Hello World" main.cpp that it instantiates. I have numerous problems.

There are red lines under "Hello" and "World" as if the compiler does not recognize them.

The first thing I did was install Code:Blocks without MinGW and it popped up showing my compilers, the only one was VS C++ 2010. Now uninstalling it and re-installing it does not allow that dialog to pop-up again.

When I first start Code:Blocks it used to say it couldn't find mspdb100.dll.

When I try to run the program it tells me it needs to build. I build it, it tells me it needs to build again... Then some console windows pop up and disappear, too quickly to read. The Build Log outputs "Process terminated with status 1104 (0 minutes, 0 seconds). 0 errors, 0 warnings.

Code by request:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

The internet hasn't helped me much. Can stackoverflow?

Thanks.

4

1 回答 1

1

Okay, so I think there are multiple possibilities. We can all agree that you code looks fine. The problem lies here:

cout << "Hello world!" << endl;
return 0;

You say, that it puts red lines under Hello and world!. Some characters might look like each other, for example “, ” and ". Therefore, open your file with the hex editor, and make sure that the " is represented by 22. You open the hex editor by navigating to the "Files" tab under the management tool window, then right clicking on your file and select "Open with Hex editor".

Then, you mention the problem with the window that opens / closes too fast. There are two solutions:

  1. Add the line cin.get(); between the hello world-line and the return-line. This pauses your application until you press enter.

  2. Go to Project > Properties... > Build targets and check the "Pause when execution ends". Make sure that the combobox above is set to "Console application".

于 2013-07-08T12:15:07.663 回答