Declaring Pascal-style strings in C

后端 未结 10 1280
渐次进展
渐次进展 2020-12-25 13:18

In C, is there a good way to define length first, Pascal-style strings as constants, so they can be placed in ROM? (I\'m working with a small embedded system with a non-GCC

10条回答
  •  再見小時候
    2020-12-25 13:47

    You can still use a const char * literal and an escape sequence as its first character that indicates the length:

    const char *pascal_string = "\x03foo";
    

    It will still be null-terminated, but that probably doesn't matter.

提交回复
热议问题