ramu said:
No. inner strings do not nest. But inner strings can contain one or
more double quote and/or one or more back slash.
The delimiter is double quote and \\ is the part of the inner
string.
The user input might be like this:
"I have a string "\\" I want to remove space in
this "string but not in the" "\"" inner string"
I assume that an inner string has the same syntax as a C string literal.
If not, please show exactly how they differ. If so, then the inner
string may represent \ and " characters by escaping them with the
sequences \\ and \". It is important to note that within string
literals a series of \s are paired:
"\\\\"
is a string literal containing \\, not the beginning of one containing
an escaped quote.
I try here to separate the actual characters in an array with the
representation as a string literal.
Start with
<string>the "bad" boys</string>
having 14 characters, where <string> and </string> are the delimiters of
a sequence of characters (to reduce confusion).
C string literal (which is a string of characters) containing those
characters:
<string>"the \"bad\" boys"</string>
has 18 characters.
A character string containing the above string literal:
<string>I saw "the \"bad\" boys" yesterday.</string>
If you give that string as input to your program, I assume you want the
output to be
<string>Isaw"the \"bad\" boys"yesterday.</string>,
but without the outside delimiters.
You could read the input string shown above, without the outside
delimiters, from an input stream.
If you wanted to represent the input as a string literal for testing,
you would code
char s[] = "I saw \"the \\\"bad\\\" boys\" yesterday.";
Your earlier example:
char s[] = "I have a string \"\\\" I want to remove space in this
string but not in the \"inner string\" ";
is a representation of the character sequence
<string>I have a string "\" I want to remove space in this
string but not in the "inner string" </string>
Using my assumed definition of inner string, the inner strings are
<string>\" I want to remove space in this string but not in the </string>
and the unterminated inner string
<string> </string>
at the very end of the subject string.
Is that what you intend?