How does one represent the empty char?

前端 未结 9 1356
闹比i
闹比i 2020-12-22 18:06

I\'m currently writing a little program but I keep getting this error when compiling

error: empty character constant

I realize i

9条回答
  •  感动是毒
    2020-12-22 18:37

    It might be useful to assign a null in a string rather than explicitly making some index the null char '\0'. I've used this for testing functions that handle strings ensuring they stay within their appropriate bounds.

    With:

    char test_src[] = "fuu\0foo";
    

    This creates an array of size 8 with values:

    {'f', 'u', 'u', '\0', 'f', 'o', 'o', '\0'}
    

提交回复
热议问题