New to programming, need a little help

Hey everyone.

I know this is simple but I'm new to programming.

I've just installed c++ express 2010 and am playing around with a "hello world" type code that I picked up off the internet. This is the code.

#include <iostream>
using namespace std;
#include "conio.h"

void main(){
cout << "Hello World";
_getch();
}

Now, I've debugged the program and it works fine, but when I change what the message will be, such as "Hello everyone", when I debug it the previous message, "Hello World", shows up in the window.

Does anyone know what the problem is here and why I can't get the new message to show up? Any help would be much appreciated.

Thanks!
You must recompile the source code for your changes to take effect.
When I click debug doesn't it recompile by itself? Or is there an option somewhere to recompile?

**edit
I've tried going under Debug and choosing Build Solution and it didn't work the first couple of times and I just tried it once more and it worked. So I tried the same thing again and it's not working again. So confusing.
Last edited on
Are you using MS VS? If so, that has a dialogue box that says "the code is out of date" when you try to run and haven't built changes to the source code. You may have accidentally said No and told it to not ask again.
I'm running MS c++ express and I'm running it off a virtual machine on my mac. I don't know if that makes any difference.

It's possible that I did say no to that but now how do I get back to the default?
Last edited on
It seems the only solution for getting it to change is deleting the executable every time I change something in the code. I've even tried changing the code to things that wouldn't allow the program to execute, it would give an error, and the program still runs.
Try changing visual studio back to its default settings; try a google search on how to do that.
MSVC++ has a menu option called build solution (under debugging). Also make sure you understand what §compiling" means.
If you are new to programing then here is a litile program for you
1
2
3
4
5
6
7
8
#include <windows.h>
int main()
{
system("color 74"); //changes the color to white bakground and red text
Beep(500, 2000);// 500 maga herts sound for 2 seconds
Beep(900, 2000);// 900 maga herts sound for 2 seconds
cout<< "hi my name is nupy!" <<endl;// displays a text
system("pause");

I use dev cpp program to make this.
@ty
You can't cout without iostream mate. and neither cout nor endl will work without declaring their namespace.

Zhuge (1521) Mar 21, 2011 at 10:40pm
Are you using MS VS? If so, that has a dialogue box that says "the code is out of date" when you try to run and haven't built changes to the source code. You may have accidentally said No and told it to not ask again.


If this was the case (as I fear I have done), how to you change it back to Yes?
Well, thanks for all the suggestions guys, but I tried it out on a regular PC, not my Mac, and it worked fine. I blame my Mac. Basically I have to delete the .exe every time I run my program and want to change something in it. It's annoying but it's the only laptop I have so I'll have to make do.

Thanks again!
Topic archived. No new replies allowed.