1. sizeof(str) calculates the total size of the array in bytes
#include<stdio.h>
int main()
{
char str[] = "hello CSDN";
printf("%d\n", sizeof(str));
}
The output result is 11
2. Strlen is to find the length of the
string. Find the end of the string'\0', how many characters appear before the'\0', the length is
#include<stdio.h>
int main()
{
char str[] = "hello CSDN";
printf("%d\n", strlen(str));
}
The output result is 10