溫馨提示×

C語言如何獲取字符串長度

小億
219
2023-06-27 20:59:25
欄目: 編程語言

C語言中可以使用strlen()函數來獲取字符串長度。該函數需要一個字符串作為參數,返回值為該字符串的長度(不包括字符串末尾的’\0’)。

例如:

#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, world!";
int len = strlen(str);
printf("The length of the string is %d\n", len);
return 0;
}

輸出結果為:

The length of the string is 13

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女