Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C++ 6
This is the forum to discuss the Wrox book Beginning Visual C++ 6 by Ivor Horton; ISBN: 9780764543883
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C++ 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 1st, 2003, 12:12 AM
Registered User
 
Join Date: Oct 2003
Location: Beaumont, TX, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Shyla_Johnson
Default Help

Hi, I am a new programmer also, I am using devcpp, and i am able to compile my programs, and run them, but the output just flashes and goes away, how can i view my output for more than a milisecond, what am I doing wrong?
Quote:
quote:
  #2 (permalink)  
Old October 7th, 2003, 01:17 AM
Authorized User
 
Join Date: Oct 2003
Location: Phoenix, Arizona, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Shyla,

try this and I hope this works for you.

at the end of your code use

return;

instead of

return 0;

  #3 (permalink)  
Old October 7th, 2003, 12:52 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why would a simple return act differently than return 0? How can you make that suggestion when shyla has posted no code, nor has she described the output of her program?

Is this a commandline application? If so, her output might be simply missing a trailing "\n" and be overwritten with the new command prompt. If it's a GUI application, perhaps the application is terminating without waiting for the user to terminate it, so a window with some text appears and promptly disappears.

Bottom line is that we need more information before answering this question. If a function in C or C++ is declared to return an int value, changing the return statement to return nothing won't fix the output problem, it'll likely generate a compiler error.


Take care,

Nik
http://www.bigaction.org/
  #4 (permalink)  
Old March 5th, 2010, 11:13 AM
Registered User
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the return to add getch() (for c) or add getchar (for c++)
i hope this works for you
  #5 (permalink)  
Old March 29th, 2010, 08:32 PM
Authorized User
Points: 100, Level: 1
Points: 100, Level: 1 Points: 100, Level: 1 Points: 100, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2009
Posts: 26
Thanks: 1
Thanked 1 Time in 1 Post
Default

you should include <conio.h> header file.
this header has a function getch(). you can use it before return statements in all programs you write in order to see the result on screen until a key is pressed.
Code:
#include <conio.h>
.
.
.
main()
{
    //your code goes here

getch();
return 0;
}
I sure am this will work if I got your question correctly !!!!
  #6 (permalink)  
Old March 31st, 2011, 03:59 PM
Registered User
 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Shyla_Johnson View Post
Hi, I am a new programmer also, I am using devcpp, and i am able to compile my programs, and run them, but the output just flashes and goes away, how can i view my output for more than a milisecond, what am I doing wrong?
Quote:
Originally Posted by sh_erfan View Post
you should include <conio.h> header file.
this header has a function getch(). you can use it before return statements in all programs you write in order to see the result on screen until a key is pressed.
Code:
#include <conio.h>
.
.
.
main()
{
    //your code goes here

getch();
return 0;
}
I sure am this will work if I got your question correctly !!!!
I second above solution by "sh_erfan" as I use same method.
plus
U can use any of following method:-
1) either use getch() as shown above 'getch() stops program until a character is pressed on keyboard (none toggle keys) so you can easily enjoy output from your program for as-long-as-you-like.'
2) OR run your program from within visual studio/vc++ ide
3) OR run your application/program from dos prompt :D using following method.
3.1) make shortcut for cmd.exe. If you know how then skip to 3.2
3.1.1) right click in side debug folder containing your win32 aplication
3.1.2) go to new and click on shortcut in sub menu
.
EITHER DO
3.1.2.1)
3.1.2.1.1) copy and paste " C:\WINDOWS\system32\cmd.exe " if u r using xp
3.1.2.1.2) change drive letter C to what-ever-is-your xp installed on.
OR
3.1.2.2)
3.1.2.2.1) click on brows and go to my computer then C drive then WINDOWS then

SYSTEM32 and then find and click on cmd
3.1.2.2.2) click ok
.
3.1.3) click next
3.1.4) click finish
3.1.5) right click on the short-cut just created with name cmd and click

properties
3.1.6) select shortcut tab if already not selected
3.1.7) select and delete the text written in front of 'Start in'
3.1.8) click apply
3.1.9) click ok
3.2) double click on shortcut just made
3.3) type name of the program and press enter key
3.4) type exit and press enter to end cmd.exe
3.5) next time just double click on shortcut, type win32 application name and

press enter. You will get what you wanted
3.6) Plus where-ever you want to use this shortcut you just made copy from

here and paste there. it will work as long as it is on same computer.

otherwise remake shortcut.
3.7) that is what u wanted so *mission is complete*
.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 06:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.