Handling spaces in command line arguments
Hi Folks,
A question which I hope isn't too silly or naive but one that is pulling my hair out.
I'm passing arguments to main, no big deal. The first argument that I'm passing is a directory where input txt files need to be processed by my program. Again nothing complicated or anything.
THe problem is windows and specfically spaces that it allows in directory names.
For example, I call my program with the below command lines.
Code:
C:\AutoChar\\autochar_classes.exe C:\Documents and Settings\adminstrator\My documents\turn57
Notice the spaces in the Documents and Settings directory and My Documents.
Now I only want to have 1 extra element in argv but because of the spaces, it adds 4 of them. As below:-
Code:
argc = 5
argv[0] = C:\AutoChar\autochar_classes.exe
argv[1] = C:\Documents
argv[2] = and
argv[3] = Settings\adminstrator\My
argv[4] = documents\turn57
So is there any syntax within DOS that I can use so that the spaces are ignored by argv and that it puts the entire command line argument at argv[1] (spaces and alll).
If not in DOS, then is there something that I can do within c++.
My problem is that I will have 2 command line arguments. One with be the input directory for input files and the 2nd command line argument will be the directory for output files. Both may contain white space in their names and I won't know for sure when one begins and one ends.
Any suggestions ?
Cheers
Starkhorn