The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself).
This should not be confused with the size of the array that holds the string. For example:
char mystr[100]="test string";
defines an array of characters with a size of 100 chars, but the C string with which mystr has been initialized has a length of only 11 characters. Therefore, while sizeof(mystr) evaluates to 100, strlen(mystr) returns 11.
Character array is a character array and string is a string. Only strings have
I was downvoted... The person who downvoted me may think that when the length of the array is greater than the actual length of the string, the compiler will automatically add
Yes None
先分析您的代码:
进一步理解
rrreee rrreeestrlen 说明
Character array is a character array and string is a string. Only strings have
I was downvoted... The person who downvoted me may think that when the length of the array is greater than the actual length of the string, the compiler will automatically add