www.delorie.com/djgpp/faq/command-line/quotes.html   search  
I have a file with a single quote in its name, but the quote seems to be stripped away when I pass it to my program...

How do I pass a command-line argument which contains double quotes?

You should escape-protect the quote characters with a backslash. For example, if you have a file called myfile.c'v, type it as myfile.c\'v when you call your program. If you have single quotes in your program arguments and you don't want those arguments to be expanded, then surround them by double quotes, like this: "*.c\'v". The program will get the string *.c'v with the double quotes stripped away.

Note that backslashes are only special if they are in front of a quote, whitespace, or backslash (they also serve as DOS directory separators, remember?).

  webmaster     delorie software   privacy  
  Copyright © 1995     Updated Feb 1995