Hey guys sorry but I just started programming like 2 weeks ago, and I recently hit a snag with using system() function to run start a program.
It works just fine when referring to a file location that has no spaces.
ex. system("Drive/stuff/example/file.exe")
but I cannot get it to work with things that have spacing in the file names.
ex. system("C:/Program Files (x86)/RIFT Game/playrift.exe")
if anyone could help me understand why its not working or show me a better way of doing this (remembering I am a beginner) I would greatly appreciate it.
This is because the shell thinks that you're calling a program named RIFT with the argument Game/playrift.exe. If the Windows shell is anything like most *nix consoles, putting quotes around (EDIT: Actually, the entire string. Duoas is right.) should fix it.
I am just trying to get down a few different ideas but the program I am trying to make a program that acts as a list to start other programs, dumb and useless I know but I am a beginner.
so for instance I am making it like this
1. Game Name
2. Game Name
3. Game Name
4. Game Name
5. Game Name
Please select one.
THen you enter the number corresponding to the program you want to start, the only problem I have encountered is file location with a space in the naming.
to get practice I am setting this up as an If Then Else statement like a check list of if its 1 do this else if its 2 do this else etc.