Linux C function() 參考手冊:strlen(返回字串長度)

Linux C function() 參考手冊:strlen(返回字串長度)

Linux C function() 參考手冊:strlen(返回字串長度)

 

資料來源:http://people.cs.nctu.edu.tw/~yslin/library/linuxc/main.htm
線上執行:http://www.tutorialspoint.com/compile_c_online.php
code2html:http://tohtml.com/

 

 

表頭文件

#include<string.h>
定義函數
size_t strlen (const char *s);
函數說明
strlen()用來計算指定的字符串s的長度,不包括結束字符”\0″。
返回值
返回字符串s的字符數。
範例

/*取得字符串str的長度*/
#include <string.h>
#include <stdio.h>
int main()
{
char *str = "12345678";
printf("str length = %d\n", strlen(str));
return 0;
}

 

 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *