How to calculate the length of a string array in the C language?
In C language, the length of a string array can be calculated using the strlen() function, which is declared in the
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, World!";
int length = strlen(str);
printf("Length of string: %d\n", length);
return 0;
}
The output is: String length: 13.