I am aware of CConstant and CString, but neither can output the single-char literal
'a'
I am aware of CConstant and CString, but neither can output the single-char literal
'a'
You could do
CArray[CString@"a", 0] // ToCCodeString
giving
"a"[0]
maybe wrap it in CParentheses.
Alternatively, just put it there verbatim (losing the type information):
CAssign[a, "'a'"] // ToCCodeString
gives
a = 'a'
CArray. Generally, bits of C code can be written in a string. You only need symbolic representation when you want to manipulate it as an expression. – Szabolcs Feb 12 '17 at 20:02