How to get the last command line argument or argument without the delimiter
-
Hi.. I use C#.NET.. I pass 4 - 5 command line arguments to my appln. for eg: /c:class /d:define /o:outputfile Infile for the first 3 arguments i can find them based on delimiters("/c:" "/d:" "/o:") But how can i find the last argument(also it can be anywhere in the command line arguments ) One thing is sure the "InFile" argument will not have any delimiters. Plz provide me the code to do this..Plz Help!!!
-
Hi.. I use C#.NET.. I pass 4 - 5 command line arguments to my appln. for eg: /c:class /d:define /o:outputfile Infile for the first 3 arguments i can find them based on delimiters("/c:" "/d:" "/o:") But how can i find the last argument(also it can be anywhere in the command line arguments ) One thing is sure the "InFile" argument will not have any delimiters. Plz provide me the code to do this..Plz Help!!!
The space is always a delimiter, unless it's in quotes. So, you can build a regex to delimit based on spaces outside quotes.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
The space is always a delimiter, unless it's in quotes. So, you can build a regex to delimit based on spaces outside quotes.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Why can't you ? There's no other way I can see, unless you're sure there will never be quotes, then the space is a delimiter. If you're unwilling to use a regex ( and if you don't know how, you should learn ), then you can always string mash your way to a solution, it's just nicer to do it properly.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Why can't you ? There's no other way I can see, unless you're sure there will never be quotes, then the space is a delimiter. If you're unwilling to use a regex ( and if you don't know how, you should learn ), then you can always string mash your way to a solution, it's just nicer to do it properly.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
it will definetly have quotes bcoz its the input file name i should pass.. So it will definetly have quotes..say eg: "d:\c plus\some.h"..so this string should always be specified in quotes..
OK, then your choices are regex or string mashing ( that is, counting spaces and quotes manually in code )
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog