I've not had the Kernighan and Ritchie C reference in years, but I remember that there was a page in there that talked about how to enter characters that were unavailable to you. (WAY back in the day, some keyboards lacked characters like ", ~, etc.)
To be clear, let me give an example. I'm not looking for a way to get quotes in strings, but rather, I want to replace this:
printf("foo");
with this:
printf([alternate sequence]foo[alternate sequence]);
For the curious, I have an automated process that involves generating C/C++ code, but the (closed source) commercial tool involved strips quotes in its data streams and the documentation is quite clear on the fact that they do not provide a way to escape them.
EDIT:
Wow, I hadn't expected such a heavy response. This might merit a little more detail on my process. I'm doing automated build systems, which means that I live with certain restrictions when it comes to changing the code I'm compiling. For now, we have to live with the assumption that I have to get a string, spaces and all, into a preprocessor definiton. I already went down the 'PreprocessorDefinition' road. This left me with my usual fallback: Define the string in the operating environment and have the project file set the definition from there:
Preprocessor Definitions WIN32;_DEBUG;THINGIE=$(THINGIE)
The hope was that I could get around MSVC's stripping of quotes in anything handed to the build with /D using a trigraph, by doing something like this in my build automation script:
ENV['THINGIE'] = "??''Yodeling Monkey Nuggets??''"
run_msbuild_command
I guess it's time for a plan C.
If you need to use the double quote inside the string, you can use the backslash character. Notice how the backslash in the second line is used to escape the double quote characters. And the single quote can be used without a backslash.
To have a double quote as a character in a string literal, do something like, char ident[] = "ab"cd"; The backslash is used in an escape sequence, to avoid conflict with delimiters. To have a double quote as a character, there is no need for the backslash: '”' is alright.
Quoting is used to remove the special meaning of characters or words: quotes can disable special treatment for special characters, they can prevent reserved words from being recognized as such and they can disable parameter expansion.
You are looking for a trigraph for "
character? I don't think one exists.
Trigraphs don't exist for all characters. Only a few characters have trigraph sequences.
None as per the standard. Try including a header with a macro:
#define QUOTE(x) #x
and generate a printf
as:
printf(QUOTE(hello));
you are thinking of trigraphs
Character Trigraph
[ ??(
\ ??/
] ??)
^ ??'
{ ??<
| ??!
} ??>
~ ??-
# ??=
but " isnt on the list
I think you're talking about trigraphs. As far as I've read, there is not one for the " character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With