Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2003, 11:12 PM
Registered User
 
Join Date: Sep 2003
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:
 
Old October 7th, 2003, 12:17 AM
Authorized User
 
Join Date: Oct 2003
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;

 
Old October 7th, 2003, 11:52 AM
Friend of Wrox
 
Join Date: Jun 2003
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/
 
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
 
Old March 29th, 2010, 07:32 PM
Authorized User
 
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 !!!!
 
Old March 31st, 2011, 02: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*
.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.