Help- Program won't run (Using MSVC++)

This is a discussion on Help- Program won't run (Using MSVC++) within the C++ Programming forums, part of the General Programming Boards category; I feel like an idiot asking you guys about what is probably a very simple thing, but...
I am using ...

Help- Program won't run (Using MSVC++)

I feel like an idiot asking you guys about what is probably a very simple thing, but...

I am using Microsoft Visual C++ 6.0 Introductory Edition, and my program won't run. I'm doing the programming on my other computer, and I don't have all of the code on hand, so it will be easier for other programmers with the same compiler to help me.

I made a simple win32 application, and added 2 lines of code to the source code file. I put #include <isostream.h> under the line with #include "stdasx.h" (or something like that... Can't remember if the last 3 characters were asx or not, but I think they were), and I added cout<<"Hello world"; (complex, isn't it?) between the braces and before the line with return 0;. I compiled the code, and it came up with 0 errors and 0 warnings. But, when I tried to run the program, it didn't run anything. Thanks in advance

// This is a VC++-specific header. Avoid it, remove the header from the project
// and all include directives from your source. Don't use this header
// unless you're using MFC, which you shouldn't for quite some time.
// You can prevent VC++ from adding the header by unchecking the
// "precompiled header" checkbox in the project wizard.
//#include "stdafx.h"
// The new C++ standard says the .h headers are deprecated.
#include <iostream>
#include <cstdlib>
// The new headers declare all elements in the namespace std.
// Follow the link to find out what this line means
using namespace std;
int main (void)
{
cout << "Hello World" << endl;
system ("pause");
return 0;
}

The system("pause"); is actually not necessary. If you run a console app as it is intended (from the console window) then the console won't close when the app ends. And if you start it from within VC++ by pressing Ctrl+F5 VC++ keeps the console window open.

Well... I'll try that one later, but I don't have time to now (stupid school!).

Anyway, I got something to run finally, but it doesn't do the "Hello World!" text it was supposed to. Instead, it just says "Press any key to continue." I've got my code here this time, so here it is...

Trash the project and start a new one. You chose a win32 project with precompiled header. This is NOT what you want. Make sure you start a CONSOLE application and an EMPTY project. Then add a source file to it (by using Project->Add->Add New Item... or something like that). Give the source file some name (like main.cpp) and write your code with a normal main and without stdafx.h.

And use the headers without the .h as I showed you.

And do the << endl thing too or else the pause message will be on the same line as the "Hello World", and that doesn't look nice.

// This is a VC++-specific header. Avoid it, remove the header from the project
// and all include directives from your source. Don't use this header
// unless you're using MFC, which you shouldn't for quite some time.
// You can prevent VC++ from adding the header by unchecking the
// "precompiled header" checkbox in the project wizard.
//#include "stdafx.h"
// The new C++ standard says the .h headers are deprecated.
#include <iostream>
#include <cstdlib>
// The new headers declare all elements in the namespace std.
// Follow the link to find out what this line means
using namespace std;
int main (void)
{
cout << "Hello World" << endl;
system ("pause");
return 0;
}

The system("pause"); is actually not necessary. If you run a console app as it is intended (from the console window) then the console won't close when the app ends. And if you start it from within VC++ by pressing Ctrl+F5 VC++ keeps the console window open.

I should mention, not all compilers have iostream working properly... so some people have to use the .h

Anyway, now that I got that problem out of the way, I've been able to do a bunch of programs from the code in the tutorials... Plus, I wrote a simple calculator (+, -, *, / only, not scientific) using what I had learned... Though I have run into a few minor problems with that one...

Originally posted by CornedBee You should get yourself a better compiler.
No, wait, you're using VC++6. So if you have to use <iostream.h> you're doing something wrong. VC++ DOES support the new style headers.