How to find the length of a string in C language?
In C language, we can use the strlen function to calculate the length of a string. This function is defined in the
Here is how to use it:
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, World!";
int len = strlen(str);
printf("字符串的长度是:%d\n", len);
return 0;
}
The output will be:
字符串的长度是:13
Please note that the function strlen returns a value of type unsigned int, representing the length of a string.