There's a mfc onDestroy, a windows Destroy callback, and .net has an OnDestroy event (I think), but this sort of doesn't solve the problem. and you've just thrown a cog into your whole argument by telling us why exit -doesn't- work. Is there a valid point to this argument remaining?
On 4/13/2011 9:29 PM, Sina Bahram wrote:
I don't see how that's the same thing though. That's platform specific, no? i could be totally off on that point, but I thought it was. This allows you to register 32 callbacks, and all your objects have destructors which get called by parents, etc, etc, so you should be good to go. Of course destructors of large object trees is a joke in C++, as anyone who has had to deal with multiple inherited classes and destructor order resolution issues will tell you. throw in some virtual functions on top of that, and the only thing you'll be destroying reliably is a bottle of something. Take care, Sina -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ken Perry Sent: Wednesday, April 13, 2011 11:25 PM To: programmingblind@xxxxxxxxxxxxx Subject: RE: again a newbee question I think Chris wants people to use the onDestroy stuff but in truth OnDestroy is not going to free up nothing if the person doesn't' add the code to it so I figure it doesn't matter either way. Ken -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Sina Bahram Sent: Wednesday, April 13, 2011 11:20 PM To: programmingblind@xxxxxxxxxxxxx Subject: RE: again a newbee question Here: void exit ( int status ); Terminates the process normally, performing the regular cleanup for terminating processes. First, all functions registered by calls to atexit are executed in the reverse order of their registration. Then, all streams are closed and the temporary files deleted, and finally the control is returned to the host environment. The status argument is returned to the host environment. http://www.cplusplus.com/reference/clibrary/cstdlib/exit/ and here: int atexit ( void ( * function ) (void) ); Set function to be executed on exit The function pointed by the function pointer argument is called when the program terminates normally. If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack, i.e. the last function specified is the first to be executed at exit. One single function can be registered to be executed at exit more than once. C++ implementations are required to support the registration of at least 32 atexit functions. http://www.cplusplus.com/reference/clibrary/cstdlib/atexit/ take care, Sina -----Original Message----- From: Sina Bahram [mailto:sbahram@xxxxxxxxx] Sent: Wednesday, April 13, 2011 11:17 PM To: 'programmingblind@xxxxxxxxxxxxx' Subject: RE: again a newbee question I'd recommend looking up how exit works. Take care, Sina -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Christopher Coale Sent: Wednesday, April 13, 2011 11:06 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: again a newbee question Also, just because exit() cleans up some standard system resources, does not mean it cleans up ALL resources. I do most of my programming with XNA, Direct3D, and the like. When you create objects that exist in graphics memory instead of RAM, you are responsible for managing that object. If I create a vertex buffer on the GPU, I am responsible for freeing that resource, not the "exit" function. Teaching beginner programmers to call exit to leave the program is just simply a horrible decision. But hey, what do I know.. On 4/13/2011 7:41 PM, Sina Bahram wrote:I don't understand what that means. Totally destroys what structure? It's an exit ... of course it destroys everything. Furthermore, exit is an extremely clean way of exiting a program. It's amillion times better than return 0.It actually calls, in reverse order of course, all functions whichregistered via atexit. It also closes streams, not only IO onesfor that matter, and it gets rid of/cleans temporary files. Quite puzzled ... Take care, Sina -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Christopher CoaleSent: Wednesday, April 13, 2011 9:38 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: again a newbee question Alright, I just wanted to force you to clarify, so you don't give Ashish the wrongi dea. ;) I grade C++ programming assignments, and I see new C++ programmers using the exit function simply because it's convenient, but it totally destroys the structure. On 4/13/2011 6:35 PM, Ken Perry wrote:Well I was using exit as a concept more than a method since depending onthegui you code in there are things like finish, exit, delete and all kindsofway to make a program die. Ken -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Christopher Coale Sent: Wednesday, April 13, 2011 9:28 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: again a newbee question Careful with saying "until you call exit." You don't want to give the impression that the exit() function is okay in a structured program, do we? ;) On 4/13/2011 6:25 PM, Ken Perry wrote:Nod you will not need things like scanf and getch and things of the like when you get into serious coding because you will be probably building windows apps of some kind and the window will remain open till you call exit. This is just while you're learning so feel free to use scanf,getch,getchar, or any of the things like read to just hold the program tillyourready to close. Ken -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of ashishrohtagiSent: Wednesday, April 13, 2011 9:05 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: again a newbee question sorry, I corrected the mistake about printf and scanf. thanks for the advice. take care, regards. ashish On 4/14/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote:I'm sorry, getch should be getchar. Also: it's fairly bad coding style to put a printf on the same line as a scanf. Unless you have good reason, try to keep your code separated. It makes it easier to read and people don't miss things quite as easily. On 4/13/2011 6:50 PM, ashish rohtagi wrote:like this?? #include<stdio.h> int main() { char me[20]; printf("What is your name?"); scanf("%s",&me); printf("Darn glad to meet you, %s!\n",me); scanf("s%",&me); return(0); } but result is still the same. can I use getch fungtion? if yes please tell me how to use it . take care, regards. On 4/14/11, Jared Wright<wright.jaredm@xxxxxxxxx> wrote:It goes right between the last printf statement and the return statement. It's job is to hold the program open at the end, so itshouldbe the last statement before return, which ends the program. On 4/13/2011 12:09 PM, ashish rohtagi wrote:hi Tyler, thanks for your suggestion, but I am unable to understand where to put second scanf. will you just once show me? take care, regards. ashish On 4/13/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote:Like ken said, use scanf to catch it before the window closes, orrunit in a command line. Here's what's happening: You open the process, and the first scanf call blocks; that is tosay,it will not process anything, it is simply waiting for the user to input something. But after it's done printing, there is no reason why it should stay open because you don't tell it to. So run from thecommandprompt, use getch() to let you hit enter before it closes or use another scanf. On 4/13/2011 9:32 AM, ashish rohtagi wrote:friends, thanks for all the encouragement. here is my problem, Iwantto use scanf fungtion. in input and output but as soon as I givemyinput and press enter the window disappears. it does not giveoutputbased on my input. here is the code. #include<stdio.h> int main() { char me[20]; printf("What is your name?"); scanf("%s",&me); printf("Glad to meet you, %s!\n",me); return(0); } On 4/13/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote:O. oops. In my defense, I haven't found coffee. :) On 4/13/2011 7:46 AM, Jared Wright wrote:It's there, just on the same line as the printf statement. On 4/13/2011 9:35 AM, Littlefield, Tyler wrote:good job on using int main, just don't forget a return 0; whenyouare done. between the printf and the closing brace. On 4/13/2011 6:36 AM, ashish rohtagi wrote:here is my code it compiles correctly but text just shows onthescreen for 1 second, I want it to stay. #include<stdio.h> int main() { printf("I will learn programming!\n"); return(0); } On 4/13/11, DaShiell, Jude T. CIV NAVAIR 1490, 1, 26 <jude.dashiell@xxxxxxxx> wrote:You didn't put your printf statement in your message, but letmemake a guess. You didn't put a (\n) in before the closing quote marksoyou just put text on the screen without a line ending. That couldbeone contributing factor. Another might be you didn't put an#include<stdio.h> statement in at the top of your program andmaybeused #include<conio.h>. If that's the case, don't use printf with conio.h unless you also include stdio.h. For conio.h, cprintf is the function you want. Hope this helps. -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of ashish rohtagi Sent: Wednesday, April 13, 2011 8:04 To: programmingblind@xxxxxxxxxxxxx Cc: punitdiwan@xxxxxxxxx Subject: again a newbee question friends, sorry here I am with another foolish question, sorrybuthere is no one to teach and I am learning myself. when I print any text on screen using printf it quickly disappears. what should I dothatit should stay? take care, regards. ashish __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind-- Thanks, Ty __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind-- Thanks, Ty __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind-- Thanks, Ty __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
-- Thanks, Ty __________View the list's information and change your settings at //www.freelists.org/list/programmingblind