Solved

restarting a program from itself

Posted on 1999-01-20
4
201 Views
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?
Thanks.
0
Comment
Question by:gilbert_chang
  • 2
4 Comments
 

Expert Comment

by:Trickster
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)
{
    PROGRAM!
    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..

Trickster
0
 
LVL 31

Accepted Solution

by:
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,

ZOPPO
0
 

Author Comment

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

Author Comment

by:gilbert_chang
ID: 1184577
Thanks Zoppo!
This works.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

776 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