Command line argument (filename)

Apr 24, 2013 at 9:37pm
Some of the arguments my program takes are file locations. As file names can contain a space the argv could be parsed half way through a path which is unwanted. What is the easiest way of retaining the space in the filename?

Thanks!
Apr 24, 2013 at 9:44pm
You don't need to worry about that if your quote them. It's not something you should have to worry about. It's a worry of the person/program calling your app.

For example, do you think mkdir cares about that stuff? You have to quote the input yourself.
 
mkdir "/tmp/test directory"
Apr 24, 2013 at 9:45pm
Enclose each file name in double quotes.
Topic archived. No new replies allowed.