kvt wrote:

> coming to the destruction of the program. i have a thought
> 1) From parent fork a child process
> 2) make the child sleep until parent finishes
> 3) after parent finished, ask the child to remove the executable one
> like...
> system("mv " argv[0] "/dev/null"); //don't point out the mistakes in
> this statement. i would like to just explain my logic. For successful
> execution, i will take a string which is equivalent to the above
> string

If you're using some Unixoid system as you apparently do, you can
usually remove the "file" even if it's still open (because you don't
directly erase a file on these systems but only remove a directory
entry). You don't need any trickery. However, there may be several names
(links) for one file, which you cannot find trivially, some temporary
directory entry might still be created upon removal (on NFS, for
example), and this of course has nothing to do with C++. Ask this on
comp.unix.programmer (f'up to).