| | |
Hello World
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Solved Threads: 1
Hi all, ok i have just started learning C++ today and i have download "Visual C++ 2008 Express Edition" and i am trying to make the "Hello World" program. I clicked on "Create Project" and then "Win32 Console Application" and then typed in the name "Hello World" then i right clicked on "Source Files" then "Add New Item" and then ".cpp" and typed in "Hello World" then i wrote into the big black page...
And then i clicked on "Build" then "Build Solution" then i clicked the green arrow "Start Debugging"
Then ERROR... The black command prompt screen shows up for about 1 second and disapears before i can even read the writing.
Please help... Thanks for comments
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main () { cout << "Hello World! "; cout << "I'm a C++ program"; return 0; }
And then i clicked on "Build" then "Build Solution" then i clicked the green arrow "Start Debugging"
Then ERROR... The black command prompt screen shows up for about 1 second and disapears before i can even read the writing.
Please help... Thanks for comments
Last edited by DonkeyKong92; Jul 20th, 2008 at 3:25 pm.
you have to add something before the return 0 to make the program stop. like this:
There are several other ways to do it too -- all of them are correct.
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! ";
cout << "I'm a C++ program";
cin.get();
return 0;
}There are several other ways to do it too -- all of them are correct.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
If you're on windows, a common way to do it is system("PAUSE"); . It gives a prompt like "Press any key to continue..." Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
Interesting, thank you for the advice, also i have another question, whenever you make a program in c++ visual 2008 does the program always appear in command prompt?
C++ Syntax (Toggle Plain Text)
int main() { }
and a console window still came up. I'm not sure if there's a way to prevent that. If you use WinMain() and create a window with the Windows API:
C++ Syntax (Toggle Plain Text)
#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR cmdLine,int nShowCmd) { }
Last edited by CoolGamer48; Jul 20th, 2008 at 9:21 pm.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
•
•
•
•
Try putting this inbetween the parenthisis of the 'int main()'
int main(int argc, char*argv[])
and on a line inbetween 'return 0;' and the string, put...
system("PAUSE");
And that should help your problems.
system("PAUSE"); Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- real world uses of C++ and Java (IT Professionals' Lounge)
- looking for "real world" C++ code (C++)
- World Webmaster (Website Reviews)
- Developing, building, and testing. How do it the best? Learning from the world leader (C)
Other Threads in the C++ Forum
- Previous Thread: HELP!!!: Seekp() & Tellg() Problem in C++
- Next Thread: What do you think?
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






Very fast responces and very helpful 