Hopefully this is really simple for somebody out there:
I want to build a string that I'm going to pass to the system() function command to do a Unix sed. I want my string to look like this:
-e '/\[SECTION\]/d'
i.e. I want my sed to remove a line that contains [SECTION]
The sed works fine, but I'm having problems creating the string in C. I'm doing this as follows:
strcpy (str, " -e '/\\\[SECTION\\\]/d' ");
My compiler is giving me this:
"tmp.c", line 9.22: 1506-235 (W) Incorrect escape sequence \[. \ ignored.
"tmp.c", line 9.22: 1506-235 (W) Incorrect escape sequence \]. \ ignored.
The string does seem to end up with what I want though, despite the warnings. I've tried removing some of the backslashes but this makes it worse.
Any ideas how I can compile this to avoid the warnings, whilst still ending up with the string I want?
Many thanks in advance.
I want to build a string that I'm going to pass to the system() function command to do a Unix sed. I want my string to look like this:
-e '/\[SECTION\]/d'
i.e. I want my sed to remove a line that contains [SECTION]
The sed works fine, but I'm having problems creating the string in C. I'm doing this as follows:
strcpy (str, " -e '/\\\[SECTION\\\]/d' ");
My compiler is giving me this:
"tmp.c", line 9.22: 1506-235 (W) Incorrect escape sequence \[. \ ignored.
"tmp.c", line 9.22: 1506-235 (W) Incorrect escape sequence \]. \ ignored.
The string does seem to end up with what I want though, despite the warnings. I've tried removing some of the backslashes but this makes it worse.
Any ideas how I can compile this to avoid the warnings, whilst still ending up with the string I want?
Many thanks in advance.