How to define an empty string in the C programming language?

In the C language, an empty string is a string with a length of 0, and can be defined in two ways:

  1. Define an empty string using a character array:
char str[1] = "";
  1. Define an empty string using a character pointer.
char *str = "";

No matter what method you use, you can assign an empty string to a character array or pointer.

广告
Closing in 10 seconds
bannerAds