Jonny <ww******@ntlworld.com> writes:
I am trying to write a C function which will dequote the string in a
char * variable, and unescape any escaped quotes, so that, for example:
"hello"
would become:
hello
and:
"\"hello\""
would become:
"hello"
much in the same way as char *argv command-line arguments are treated
when passed to function main.
You'll need to define the problem more precisely. The language
doesn't define any particular treatment of command-line arguments;
they're just made available to the program by some system-specific
means.
If you were on a Unix-like system, I'd say that you're probably trying
to duplicate what the shell does with command-line arguments before
invoking a program; for example
echo "\"hello\""
translates each \" to " and drops the outer " characters. This is
often very similar to the way string literals are treated within a C
program, but it's not identical. It can also vary from one shell to
another, and even within some shells depending on what options are
specified.
That's just one example of what you might be talking about. It's
likely to be different on other operating systems.
Once you've defined the problem, try implementing a solution in C. If
you have problems with it, post here again and we can try to help.
If this is a homework assignment, please say so.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.