473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

My first C++ program failed on me revisted

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
6 2229
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
> 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
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

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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: hokiegal99 | last post by:
Hi Guys, This is my first C program. I started programming in Python. Please look over this source and let me know if I'm doing anything wrong. I want to start out right with C, so if you see...
4
by: chellappa | last post by:
Hi, This is program for socket program for server and client ... but data send from client and receive by server but i can t sen d message fro m server to client ... check i mistake .. i treed...
4
by: bienwell | last post by:
Hi all, I'd like to use TRY, CATCH to open my database connection. I have 2 servers that have the same table name "myTable". If the first connection to Server1 is failed, then the program will...
9
by: santosh | last post by:
Hello all, I've put together a small program to count the number of characters and 'words' in a text file. The minimum length of a word, (in terms of no. of characters), as well as word...
1
by: verge | last post by:
hello everyone! how's it going? like everyone in here im in need of some help and good friendship along the way...take a look at this: //MODIFIED SO IT DEALS WITH WINDOWS FTP USING ACTIVE...
7
by: illegal.prime | last post by:
Hi all, I've got a client/server application and just wanted to ensure that this is expected behavior. I recently set the following configuration in Visual Studio: Debug->Exceptions->Break Into...
4
by: neptundancer | last post by:
Hi, to extend my skills, I am learning python. I have written small program which computes math expression like "1+2*sin(y^10)/cos(x*y)" and similar, so far only + - * / ^ sin con tan sqrt are...
1
by: sa6113 | last post by:
which program I have to install for using paramiko for sftp between a two windows machine in local network?? I have installed freeSSHd for server machine but I got an Authentication failed erro...
0
by: sa6113 | last post by:
which program I have to install for using paramiko for sftp between a two windows machine in local network?? I have installed freeSSHd for server machine but I got an Authentication failed erro...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.