strlenを使って文字列の長さを見つける方法
2886 ワード
C言語でStrlenを使った文字列の長さを見つけるためのチュートリアル関数は、与えられた文字列の文字数を数え、長い符号なし整数値を返します. ヘッダーファイル内のC標準ライブラリで定義されています.
NULL文字が遭遇したときにカウントを停止します.Cでは、NULL文字は文字列の末尾と見なされます.
実施例
出力
我々のサイトFind the length of a string using strlen() in Cの上で完全なポストを読んでください
我々のサイトMeshWorldの上で他のポストを読んでください
ハッピー😄 コーディング
With ❤️ から🇮🇳
char saying[] = "Better late than never";
strlen(saying);
実施例
#include <string.h>
#include <stdio.h>
int main()
{
char planet[] = "Earth";
printf("\n Using strlen for planet without null character: %zu", strlen(planet));
printf("\n Using sizeof for planet with null character: %zu", sizeof(planet));
return 0;
}
出力
Using strlen for planet without null character: 5
Using sizeof for planet with null character: 6
strlen()
関数がNULL文字<string.h>
に対してカウントされず、strlen()
関数が実行されます.我々のサイトFind the length of a string using strlen() in Cの上で完全なポストを読んでください
我々のサイトMeshWorldの上で他のポストを読んでください
ハッピー😄 コーディング
With ❤️ から🇮🇳
Reference
この問題について(strlenを使って文字列の長さを見つける方法), 我々は、より多くの情報をここで見つけました https://dev.to/cooldashing24/how-to-find-the-length-of-a-string-using-strlen-in-c-2od3テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol