im very much noob here (just started it 2days ago lol) im using Dev C++ Bloodshed Software (lol dont know how to say it in correct technical grammar).
Hello World is d most basic (like hacking pinball scores when using CE) but my problem is after i compile d source file and run it, the only thing that happens is that the command prompt (or command.com whatever) flashes for only a few milliseconds. I cant see then if the messege "Hello World" had appeard...
help me pls.. lol
when creating hello world, is it at new source file? or at new project? or at new resouce file? lol pls support d noob thnx !
C++ very noob here pls help ! thnx?
Hi,
Try creating a batch file to run your program and put pause as the last command e.g.
myapp.exe
pause
saved as myapp.bat
When you run this the window should stay on the screen for you to read until a key is pressed.
It is most likely a new project (console app)
Reply:Just try out by giving
getch();
(or)
getche();
just before the closing of main()
It ll wait for u to see the message.
You have to include
#include%26lt;conio.h%26gt;
Reply:a). Run your compiled program from the command line.
or
b). Set a breakpoint on your program's return statement
or
c) Step through the program using the debugger.
or
d) Add the line of code:
while(1);
to create an infinite loop.
If you don't know how to do step b or c, you are eventually going to learn, so pull out the manual now and learn how to do it.
Reply:put this statement right before return 0 in your int main function
system("pause");
example...
#include %26lt;iostream%26gt;
using namespace std;
int main()
{
//all code here
cout %26lt;%26lt; "almost done with program, going to stop here" %26lt;%26lt; endl;
system("pause");
return 0;
}
this will give a message to push a key to continue to the end of the program.
to answer your questions...
DEV C++ is called a compiler
helloworld.cpp is called a source file
helloworld.cpp and other files relating to it, such as helloworld.h would be considered a project (which means your into more advanced programming stuffs)
and helloworld.exe would be a new program, created by you.
I don't really think your a noob, your more of a newbie
Reply:Here ya go.
Using Dev-C++ (The compiler that you use aswell)
I have coded a simple Hello World program for you
and even added some comments on what-does-what.
(Also, you want to make a new source file.)
//Pre-Processor directives
#include %26lt;iostream%26gt;
#include %26lt;conio.h%26gt; // for getch();
//Specified namespace
using namespace std;
int main()
{
//Cout object
cout %26lt;%26lt; "Hello world";
//Get keyboard input.
getch();
}
Enjoy,
- Void
Reply:The problem is that your IDE runs the program and closes it before you can see it.. there should be an option to not have it do that... or you can put a breakpoint in the program and have the debugger stop at that point... or... you can open a command window and execute the program from there... (probably the best option)... although the batch idea issued before isn't a bad option either...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment