yeah yeah, system is bad. But the fact of the matter is that everyone that has spoken that statement has not suggested an alternative to it. So, I ask you now: Is there an alternative to useing System()? I will not download new libraries, etc...
System Specs:
-Win7
-MinGW + Codeblocks
I believe that's all you need to know to answer my question. If you need any more information, please ask.
This is not homework/schoolwork, I am doing this in my own time, and useing the internet to help. All of your advice is very much appreciated!!
Don't mean to be rude, but naraku example is not recommended to use. It will work without issues in this particular case, but it will have problems in others, especiaaly in paths with spaces. Read MSDN documentation for how exactly CreateProcess works.
The recommended way is to always use NULL as first argument and use full path and command line arguments enclosed in quotes as second parameter for CreateProcess. There are numerous examples on the web.
Also the second argument must be a writable string, not a constant string if you use Unicode version of CreateProcess.
@modoran
Looks like I missed some bits when I skimmed through the documentation
If the executable module is a 16-bit application, lpApplicationName should be NULL, and the string pointed to by lpCommandLine should specify the executable module as well as its arguments.
The first parameter, lpApplicationName, can be NULL, in which case the executable name must be in the white space–delimited string pointed to by lpCommandLine. If the executable or path name has a space in it, there is a risk that a different executable could be run because of the way the function parses spaces. The following example is dangerous because the function will attempt to run "Program.exe", if it exists, instead of "MyApp.exe".
The recommended way is to always use NULL as first argument and use full path and command line arguments enclosed in quotes as second parameter for CreateProcess
Actually, this statement is incorrect. Microsoft actually recommends the opposite, for security reasons (the problem they are referring to is paths with spaces). From the MSDN entry on CreateProcess():
To avoid this problem, do not pass NULL for lpApplicationName. If you do pass NULL for lpApplicationName, use quotation marks around the executable path in lpCommandLine, as shown in the example below.
You should only ever pass NULL as the first parameter by choice if you need to support 16-bit apps.