I am writing a console application that considers a series of decomposition functions. There is a requirement that the application ask the user to "Try again? Y / n" and restart when entering y .
I implement it like this:
wchar_t tryAgain; do { puts("\n Wanna try again? (y/n)"); fflush(stdin); } while(scanf("%c", &tryAgain) !=1); switch(tryAgain) { case 'y': system(argv[0]); break; case 'n': system("exit"); break; default: system("exit"); } But the problem arises: in this way a new copy of the program is created in memory:
This is not quite rational, and therefore the question arises: is it possible to restart the application instead of creating a new instance in memory?

man execv(there is still some kind of analog in Windows) - avp