System() Can't Open File

Hi,

I am trying to use system("...") to run an executable that takes a file as an input i.e. system("...\\folder\\executable picture.bmp").

When I run the executable from the command line everything works OK, but when I run it from my program using system(), I get an error saying it was unable to open the input file (picture.bmp).

Why is this the case?

Thanks,
Rob


Edit:

Ok, so the problem has become that I have spaces in my file name.
When I run,
system(" \"H:\\Visual Studio 2010\\...\\folder\\executable\" ")
This works and loads the executable .

However, when I try to include the input file,
system(" \"H:\\Visual Studio 2010\\...\\folder\\executable\" \"H:\\Visual Studio 2010\\...\\folder\\picture.bmp\" ")

It no longer recognises the quotations and says
'H:\Visual' is not recognised as an internal or external command.

Clearly the problem lies with putting to paths in quotations, is there any way to get around this?

Note that when I type the above into the command prompt (without unnecessary \'s) the program runs fine.

Edit Edit:
Got it, had to add another quotation mark around everything i.e.
system(" \"\"H:\\Visual Studio 2010\\...\\folder\\executable\" \"H:\\Visual Studio 2010\\...\\folder\\picture.bmp\"\" ")
Last edited on
Topic archived. No new replies allowed.