How to escape or terminate an escape sequence in C

后端 未结 2 1442
鱼传尺愫
鱼传尺愫 2020-12-19 00:11

I have sequences of characters I\'m feeding to a decoding function:

For example:

\"\\x05three\"

(Yes, that\'s a Pascal-style string

相关标签:
2条回答
  • 2020-12-19 01:00

    Yes, you cant try "\004four" for instance. Actually, even "\04four" will probably do, because f is not an octal number.

    0 讨论(0)
  • 2020-12-19 01:13

    You just write strings next to each other:

    char a[3] = "1\02"   // {'1', '\2', '\0'}  
    char a[4] = "1\0""2" // {'1', '\0',  '2', '\0'}
    
    sizeof("1\02") // 3
    sizeof("1\0""2") // 4
    
    0 讨论(0)
提交回复
热议问题