How is an empty string represented in the C programming language?

In C language, an empty string can be represented by a character array of length 1 containing only a null character ‘\0’. This array can be initialized as “” or {‘\0’}. For example:

char str[] = ""; //空字符串

Alternatively, the empty string can also be represented using a pointer, pointing to an empty character ‘\0’. For example:

char *str = ""; //空字符串
Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds