Should I get an error message?

Ive just started learning C++ in Microsoft Visual C++. If I write this:
1
2
3
4
5
6
7
8
9
10
#include "stdafx.h"
#include <iostream>
using namespace std;

int main() 
{
	cout << "cheese";
	cin.get();
	return 0;
}

It obviously prints out cheese. But when I change it to this:
1
2
3
4
5
6
7
8
9
10
#include "stdafx.h"
#include <iostream>
using namespace std;

int main() 
{
	cout << "bacon"
	cin.get();
	return 0;
}

It still prints out cheese. I left out the semi colon on purpose. But why isn't it recognizing that cheese isn't there any more? And why isn't an error message showing up at the bottom of the screen saying that there is a syntax error or something as I left out the semi colon?
Last edited on
I had this problem when I first started. The problem is your going back into the command window and typing a.out after you save your changes. Instead type g++ file name. This will reload the new saved file. Then type a.outnto execute with new changes
And this is also the reason it's not showing the syntax error. Unless you reopen the new saved file with g++ , every time u type a.out it will just reopen the last file that was executed
closed account (zb0S216C)
Did you rebuild the program after you made the changes?

Wazzak
oh whats the difference between rebuild and start debugging? Sorry if thats a dumb question haha! :)
Rebuild the program is g++ file name in your command window. It basically loads your new program and dumps the one you just used.
closed account (zb0S216C)
Rebuilding forces the compiler to discard the last build of your program and builds a new one which will apply all changes in the source code. Debugging is the process of locating bugs in source code and then removing them. In computing, a bug is a glitch in a program which can cause a program to behave unpredictably.

@ProgrammingNewb: Why are you assuming Lindz is using GCC's compiler when he/she clearly stated he/she is using Visual C++?

Wazzak
Last edited on
Because I didn't realize the function is different for different compilers, obviously if they actually responded to my direct answer I could hAave clarified.
Ok thank you so much for your help. So does that mean every time I want to run a program do I have to press build solution and then start debugging?
Yes
closed account (zb0S216C)
Not necessarily. Once a program is built, you can execute it as many times as you want. The only time you need to rebuild a program is when you've made changes to the source code. Debugging is only necessary when your program behaves in an unexpected way.

A compiler will generate two programs: a debug version and a release version of your program. When you begin debugging your program, you'll be using the debug version of your program. When the majority of the bugs are removed, you'd build your release version of your program.

Wazzak
Last edited on
ok sweet! So if I just want to run the program after its built what do I press if it isnt start debugging?
Anyways thankyou so much! Yous have really helped :)
Topic archived. No new replies allowed.