I'm totally new to C++ and when I try to execute the simple program I have
written, it closes the console application as soon as it has finished
excuting. This obviously means I cannot see the contents of the console
window.
I'm developing it using Visual C++ 2003, using the console application
template. 5 3166
James wrote: I'm totally new to C++ and when I try to execute the simple program I have written, it closes the console application as soon as it has finished excuting. This obviously means I cannot see the contents of the console window.
I'm developing it using Visual C++ 2003, using the console application template.
Have you tried starting the application from a console that you have already
opened?
--
Chris Gordon-Smith
London http://www.simsoup.info
"Chris Gordon-Smith" <us*********@my .homepage> wrote in message
news:3r******** ****@individual .net... James wrote:
I'm totally new to C++ and when I try to execute the simple program I have written, it closes the console application as soon as it has finished excuting. This obviously means I cannot see the contents of the console window.
I'm developing it using Visual C++ 2003, using the console application template.
Have you tried starting the application from a console that you have already opened?
So simple. Can't believe I didn't think of it myself.
Thank you.
911!
NO!
This is is the way you do it, please take my advice...
int main(){
std::cout << "I want to see this message" << std::endl;
std::cin.get(); // pause until I press enter...
return 0;
}
The std::cin.get() is what you want to use.
This the true C++ way to handle your problem.
Have fun James!!
"jalkadir" <ja******@goson ic.ca> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. . This is is the way you do it, please take my advice... int main(){ std::cout << "I want to see this message" << std::endl; std::cin.get(); // pause until I press enter...
If every program waited for a character from its standard input before
exiting, not much could be achieved in today's systems.
return 0; }
The std::cin.get() is what you want to use. This the true C++ way to handle your problem.
Taking a character from the standard input has nothing to do with the OP's
_program_; that is not a requirement of the program. The program does its
job and exits. No problem there...
The OP's problem is about not being able to see the output of the program.
That problem can be solved in a number of ways, one of which is to start it
in an environment with some history buffer.
Ali
James wrote: I'm totally new to C++ and when I try to execute the simple program I have written, it closes the console application as soon as it has finished excuting. This obviously means I cannot see the contents of the console window.
I'm developing it using Visual C++ 2003, using the console application template.
If you start the program out of the IDE, press "Ctrl-F5" instead of "F5"
to start. Then the console remains open with the message
"Press any key to continue"
at the end.
Maett This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tuno |
last post by:
I'm relatively new to Java Swing programming. I have a console application
that processes text files and while doing so I want to suspend the execution
when an error is encountered that requires the user to make a choice. I want
to do that with my own JFrame that allows the user to edit the bad data in a
GUI and then click "Accept" or "Ignore". If the user clicks "Accept", the
JFrame contributes the data to the standard output being...
|
by: Kay Schluehr |
last post by:
The documentation of the Python console behaviour is not correct
anymore for Python 2.4.1. At least for the Win2K system I'm working on
'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc.
The Python interpreter tells me instead:
>>> quit
'Use Ctrl-Z plus Return to exit.'
Nah, 'Ctrl-Z' is now undo :-)
|
by: Fred Iannon |
last post by:
All,
I have developed an application that needs to run
in one of two modes:
(1) IF NO command line parms are provided I would
like it to run as a Window form application
(i.e. /target:winexe) with a Main form, etc. and with
execution returing to the command line AS SOON AS the
program STARTS
(2) If a command line parm IS provided I would
|
by: news.microsoft.com |
last post by:
Hi everyone,
I need some help (may be in the form of some sample code) for the subject
question.
I have an ASP.NET/C# application. I need to do quite a few tasks when the
session ends. I don't want to depend on the session timeout factor since it
may end too soon or it may hang around too long. I can't find any event
that fires when the browser closes. The Session_End event handler in the
Global.asax does not execute until the...
|
by: Rob |
last post by:
When issuing...
System.Console.Write and WriteLine commands... the program shells out to
Command prompt, displays message, and closes... there is no time to view
what is shown,,, how can you keep the console up in order to view the
contents ?
Thanks
| |
by: noridotjabi |
last post by:
What is the purpose of the function pointer? Why do you need a pointer
to a function. I cannot really think of any application where this is
the only or even easiest solution to a problem. I'm sure there are
really good aplications for it I just cannot think of any, so if anyone
can tell me why a pointer to a function is nessisary and when it
can/should be used I would apreciate that. Thanks.
Nori
|
by: Marin |
last post by:
Right now my solution to this is adding Console.ReadLine at the end but I'm
wondering if it's possible to do it automatically?
If I chose "Start without debug" it does just that, it pauses right before
the console window closes, but "Start with debug" closes the window right
away.
|
by: Tharpa Roberts |
last post by:
Under Visual C++ 6.0, if you made a command-line program, it would stay open
after execution, and then you would press any key to close it.
Under Visual Studio 2005, if you make a C++ command line program, the
program instantly closes after execution (not even enough time to read what
it says) if the program created its own command line window. (It does stay
open if you run the program from a command-line.)
What do I have to do to...
|
by: collinsp |
last post by:
Can any one help me with the code below. I am just learning C and any
help would be appreciated. When I run the program the console opens,
the printf in the function getData prints, I enter the data and when I
hit return the console closes.
Thanks
// Unit 4 Project 44.cpp : Defines the entry point for the console
application.
//
//This program creates customer;s bills for a carpet company
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |