restarting a program from itself

Posted on 1999-01-20
Last Modified: 2010-05-18
After the user finishes with the program I write, I want the program to restart automatically (it starts in a 'sleep' mode).
What is the best way to restart the program from it's own end?
Question by:gilbert_chang
  • 2

Expert Comment

ID: 1184574
Is there any reason why you can't just include the main-code in a while-loop? For example using

int looping = 0;
while (looping == 0)
    if (userWantsToQuit)
        looping = 1;

I often use a Timer which runs the program when I want the program to restart after a set number of seconds..

LVL 30

Accepted Solution

Zoppo earned 50 total points
ID: 1184575
At the end of your programm use something like

_spawnl( _P_NOWAIT, lpszAppFullPath, lpszAppFullPath, NULL );

hope that helps,


Author Comment

ID: 1184576
Trickster - what about threads and other memory structures I created in the program.
Trying to start them over might cuase explosions...right?

Author Comment

ID: 1184577
Thanks Zoppo!
This works.

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now