|
Answer» The following code works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"
Code: [Select]#include <iostream> using namespace std;
int main() { cout << "\n"; cout << "\t"; cout << "Hello World\n"; cout << "\n"; cout << "\n"; system("pause")
return 0; }
Anyone know why it won't work in "Microsoft Visual C++"?Not quite sure why it works in one but not the other, considering there's a semi-colon missing. Try this instead: Code: [Select]#include <iostream> using namespace std;
int main() { cout << "\n"; cout << "\t"; cout << "Hello World\n"; cout << "\n"; cout << "\n"; system("pause");
return 0; } Quick edit: I compiled it myself to make sure it works, and it does. Although I am using Visual Studio 2005. See if it works, and if not, try it without system("pause").Your code, before the fix, should not compile in either program. I find it odd that it did.Sorry, The missing semi-colon was missed when I was typing it into the FORUM. The correct code (with the semi-colon) works in "Dev" but not "Visual C++".
Sorry about that mistake.
and Alan when I TAKE the system("pause") out the command prompt windows just comes up and automatically closes, so you don't get a chance to read what it prints out.Would "Dev" have different libraries than what "MS Visual C++" has?I've just compiled and run the above code and it works. I'm downloading Visual C++ 2005 Express Edition to see if that works. This will take about 10 minutes or so.
EDIT: The iostream.h file should be the same on VC++ and Dev-C++.
EDIT 2: In order to compile a Console program like this, Create a Blank Project (Under General in my VC++). Then make the .cpp file and add it to your project. After doing that, I was able to compile your program. (But what a pain it was.)
I'll add SCREENSHOTS in a moment.My program doubtlessly looks different, but you'll get the main idea:
From there, BUILD normally. (Though personally, I just prefer Dev-C++. It's cleaner and easier. )Thanks so much for your help. Although, It still doesn't work in "MS Visual C++". Lol I'm new to C++ and I just heard that "Dev" had it's libraries out of date or something, So I installed "MS Visual C++". But as I've realized already and with your comment:
Quote (Though personally, I just prefer Dev-C++. It's cleaner and easier. Smiley)
I'm just going to stay with "Dev". Plus it's open source - Yay!
|