473,735 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program Closes

hi all,

im trying to write my first c++ program. a success, but i can't get the
window to stay open after user enters input. it just automatically closes.
right now the end of my program looks like this:

return 0;

}

anyone know what i'm doing wrong?

thanks, eric
Jul 23 '05 #1
1 3273
On Sat, 21 May 2005 06:00:26 UTC, "Eric Whittaker" <ew****@adelphi a.net>
wrote:
hi all,

im trying to write my first c++ program. a success, but i can't get the
window to stay open after user enters input. it just automatically closes.
right now the end of my program looks like this:

return 0;

}

anyone know what i'm doing wrong?

thanks, eric


Eric,

We need a little more information to help you. What kind of
program are you writing? If the code is small enough perhaps
some of it could be posted.

You mention that the end of your program has the above
statement. I'm going to guess that you wrote a simple
"hello world" type program. Thatwould indicate to me
that the program was a console program or whatever your
operating system calls it. Anyway, if you're using a
windows based view by running the program by "clicking
on it from Explorer under Windows" and the program is
just a console application, that is the correct behavior.
Two things are happening. One is that your program is
running. Second, once the program has run the
automatically started console session closed. To change
this behavior, open a console session and use the
command line to move to and run your program. When the
program is done you will still have the console window
open so you can view the results.

If you are talking about the above line being the
end of your program and the program have a graphics
interface (window), the end of the program will end
the window. In that case you need to provide some
method to keep the program open for a while longer.

If all else fails, ask one more question with your
program -- "press enter to end program" and wait
for input.

David

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1399
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different documents (txt, MS Office files, pdf, pictures,…) from inside my app. It must start the file with the adequate external program (Notepad, MS Office programs, Acrobat Reader, some Picture viewer,... ) and be notified when this programs closes the...
5
7364
by: Phil Galey | last post by:
VB.NET 2002 on Windows 2000 SP 3 When I start my program, the NotifyIcon appears in the tray, as it should. However, when I close the program, the NotifyIcon remains until I hover over it with my mouse. If I don't hover over it to make it disappear and then open the program again, another one is added, resulting in a multiplicity of the icon in the tray. I've even tried setting its Visible property to false, followed by a call to the...
3
1280
by: Luke | last post by:
I have a program that exits just fine when you close it manually, but throws an unhandled exception when I try to log off windows. It suggests I enable the JIT debugger, but when I compile the program in debug mode and enable JIT debugging it closes fine, though the logoff process is aborted. I am using a couple of activex controls that .net generated wrappers for, so I don't know if that has anything to do with it, but my program closes...
2
1228
by: dkoco | last post by:
I have a C#.Net program that once a button is clicked it goes to a public class(called Tal) and gets data in a vector, then exits the class, and goes back to the main form(program). I will do this task over and over. I want to take the data ,do many(over 20) calculations, and go back to the program. How can I get access to the data array(vector) from the main program? I keep getting different errors and have tried so many different ways. Thanks...
1
3995
by: amir | last post by:
Hello all, I have a db file .mdf in my program. I wander if it saves it everytime values are inserted and if not how can it be done ? furthermore i want to know where can i see the .mdf file after the program closes and with what program. cheers, amir.
4
1984
by: canteyn | last post by:
Ok here is my problem. I am coding a program that uses 3 different functions, and the end result is that the program reads in (x,y) points from a file, and then outputs those points to another file, and then calculates the area of the points(which form a polygon). I am able to compile the program just fine, but every time I try and run the program I just get a "segmentation fault". It may be in regards to my arrays, in fact I am almost sure...
3
1296
by: manontheedge | last post by:
I'm having a problem when I work with Access using VB6. I don't have a problem controlling Access, but I want the Access file to stay open when the program ends...but it always closes itself, and I don't know why. I stepped through my program, and it stays open literally until the second the program stops running. How can I get it to stay open and visible on the desktop...is there some trick to it? it's really strange, I know I'm opening...
2
9153
by: revenant81 | last post by:
I'm writing a program which has to execute a command, get its output and show it on a treeview. This command runs for a very long time. I want to end the execution of the command when the user closes my application. Right now I'm using an object my_child of type subprocess.Popen to execute the command, inside a thread with an infinite loop where we constantly ask for its output.
4
1873
by: Jonny Relentless | last post by:
After adding a form to a C# program, I am unable to use it. I want to use form1 as a sort of menu, so that when the user clicks a button, form1 will close and form2 (or form3, etc) will open. What code must I write to make this happen? I am new to programming, so go easy on me with the explanation please. Thank you for any help you can offer.
0
8964
marktang
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...
0
8786
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,...
0
9327
jinu1996
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...
1
9253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9201
tracyyun
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...
0
4564
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...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2740
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2190
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.