Declare String Variables in C
In C language, to declare a string variable, you need to use an array of type char to store the string content. Below is an example code for declaring a string variable:
char str[100]; // 声明一个包含100个字符的字符串变量
char str[] = "Hello World"; // 声明并初始化一个字符串变量
In C language, strings are actually stored in the form of character arrays, allowing us to declare and manipulate string variables using array methods. It is important to note that strings in C language are character arrays with a null-terminated character at the end, represented by the \0 character to indicate the end of the string.