By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,897 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,897 IT Pros & Developers. It's quick & easy.

My first C++ program failed on me revisted

P: n/a
complete code:

#include <iostream>

int main()
{
std::cout << "Hello World" << '\n';
return 0;
}
I'm using Dev C++ version 5.0 to compile the program. I don't get any errors
when compiling, but when I execute the program a DOS windows opens and then
closes straight after. I assume that this means there is nothing outputted
on screen. Any help appreciated.
WD

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003
Jul 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Web Developer wrote:
complete code:

#include <iostream>

int main()
{
std::cout << "Hello World" << '\n';
return 0;
}
I'm using Dev C++ version 5.0 to compile the program. I don't get any errors
when compiling, but when I execute the program a DOS windows opens and then
closes straight after. I assume that this means there is nothing outputted
on screen. Any help appreciated.

Your code is fine. It's just that after writing the message to cout
there was
nothing for the program to do -- so it went away.

You could out a call to std::getchar() before the `return' statement to
keep it around.

BTW - this is not a C++ question; it's related to your IDE.

HTH,
--ag
--
Artie Gold -- Austin, Texas

Jul 19 '05 #2

P: n/a
> You could out a call to std::getchar() before the `return' statement to
keep it around.


Or learn how the command line works as any worthwhile developer should.
It is not hard to learn and is absolutely necissary for anyone serious
about learning to program for or administer systems. Not learning to
use the command line is like turning bolts with a pair of pliers - it
might work much of the time but you would certainly be better off
learning to use a wrench.

NR

Jul 19 '05 #3

P: n/a
Noah Roberts wrote:
You could out a call to std::getchar() before the `return' statement
to keep it around.

Or learn how the command line works as any worthwhile developer should.
It is not hard to learn and is absolutely necissary for anyone serious
about learning to program for or administer systems. Not learning to
use the command line is like turning bolts with a pair of pliers - it
might work much of the time but you would certainly be better off
learning to use a wrench.

NR


No argument there! ;-)

--ag

--
Artie Gold -- Austin, Texas

Jul 19 '05 #4

P: n/a

You could out a call to std::getchar() before the `return' statement to
keep it around.


Or learn how the command line works as any worthwhile developer should.
It is not hard to learn and is absolutely necissary for anyone serious
about learning to program for or administer systems. Not learning to
use the command line is like turning bolts with a pair of pliers - it
might work much of the time but you would certainly be better off
learning to use a wrench.

NR


how does using a cmmand line fix my problem?

WD

Jul 19 '05 #5

P: n/a

how does using a cmmand line fix my problem?

WD


Nevermind that comment. Although, it is a nusiance to go to DOS and run the
program everytime you change some code. Maybe the Dev C++ has something like
command line?
WD

Jul 19 '05 #6

P: n/a
On Sat, 02 Aug 2003 12:50:42 +0930, Web Developer wrote:
Nevermind that comment. Although, it is a nusiance to go to DOS and run
the program everytime you change some code. Maybe the Dev C++ has
something like command line?


Make a function void pause() that prints something like "Program done
press any key to exit" and reads a character before it returns. Put that
at the end of your main.

Make a second function void my_exit(int ec) that calls pause and then
exit(ec), use that wherever you would use exit.

Remove the functions and the calls to them if you're releasing your
programs.

hth
NPV
Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.