Hello World not working with Code::Blocks

Hello I am new to these forums, sorry if this has been brought up before, but this seems to be a specific problem related to Code::Blocks. I downloaded a fresh release today so it is the latest version of CB.

I pasted a simple HW program into the editor and clicked 'run' and it prompted a message saying it hadn't been built yet and asked if I wished to build it, so I answered yes, but this just triggered endless prompts. If I clicked 'no' it ran as a window with the following written: 'Process returned 1975514249 <0x75BFF489> execution time etc etc'

I am using the GNU compiler and it does the same thing for any other program I enter, so it can't be in the code itself. I imagine there is some problem with the default compiler settings but I uninstalled CB before re-downloading it today to make sure everything was ok.
Do you have dev-cpp? If not go download it and install it.
Code::blocks is generally to be recommended more highly than dev-cpp.

But if you do intend to try the latter, make sure it is the orwell version, there are unfortunately obsolete versions still out there. http://orwelldevcpp.blogspot.co.uk/
I used to use that but got CB as it was recommended to me as being better. I am using DevC++ now and made this to test it
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

main ()
string mayorname, cityname;
cout << "** VirtuCity **\n";
cout << "Build the city of your dreams! Or your nightmares! Or your daydreams!\n";
cout << "You are the Mayor!\n";
cout << "What is your name, Mayor?\n";
cin >> mayorname;
cout << "Your name is\n";
cout << mayorname;
cout << "What is the name of your new city?\n";
cin >> cityname;
cout << "Your city is called\n";
cout << cityname;
return 0;

If I enter 'Sherlock Holmes', for instance, it prints 'Sherlock', then automatically prints under the next question a blank line, then after Your city is called it says 'Holmes'?
Last edited on
Try doing

getline(cin, cityname);

That should allow you to get the whole input
Topic archived. No new replies allowed.