3

I am aware of CConstant and CString, but neither can output the single-char literal

'a'
masterxilo
  • 5,739
  • 17
  • 39

1 Answers1

2

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'
masterxilo
  • 5,739
  • 17
  • 39
  • 1
    Just put it there verbatim, there is really no need for the complication with 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