()
 




 









 








 






























 










 
 




   



稿

 



















   




 


1  





2  





3  



3.1    







4  





5  





6  














strcmp






English
Español
Français
 


 











 




















 









   


 






 




 










URL
QR

 




/  




PDF 

 


















: Wikipedia
 


strcmp2つの文字列を比較 (compare) するC言語関数である。 標準Cライブラリの文字列操作関数群が宣言されているヘッダーファイル string.h に含まれる。 ストリングコンペアストリングコンプなどと呼ばれることが多い。

書式[編集]

#include <string.h>
int strcmp(const char *s1, const char *s2);

説明[編集]

strcmp() 関数は2つの文字列 s1 と s2 を辞書式順序で比較する。この関数は、s1 が s2 に比べて

  1. 小さい場合
  2. 等しい場合
  3. 大きい場合

に、それぞれ

  1. ゼロよりも小さい整数(負数)
  2. ゼロに等しい整数(ゼロ)
  3. ゼロよりも大きい整数(正数)

を返す。

関連関数[編集]

#include <string.h>
int strncmp(const char *s1, const char *s2, size_t n);

strncmp() 関数は2つの文字列s1とs2を最大n文字比較する。

大文字・小文字を区別しない比較関数[編集]

規格や処理系によっては、比較時に大文字・小文字を区別しない関数を独自の拡張として実装しているものもある。

[1]

#include <strings.h>
int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, size_t n);

[2][3][4][5][6]

#include <string.h>
int stricmp(const char *string1, const char *string2);
int strnicmp(const char *string1, const char *string2, int n);
int strcmpi(const char *string1, const char *string2);
int srtcasecmp(const char *string1, const char *string2);
int strncasecmp(const char *string1, const char *string2, size_t count);

[7][8]

#include <string.h>
int _stricmp(const char *string1, const char *string2);
int _strnicmp(const char *string1, const char *string2, size_t count);

脚注[編集]

  • ^ IBM Knowledge Center - stricmp() — 大/小文字を区別しないストリングの比較
  • ^ IBM Knowledge Center - strnicmp() — 大/小文字の区別をしないサブストリングの比較
  • ^ IBM Knowledge Center - strcmpi() — 大/小文字を区別しないストリングの比較
  • ^ IBM Knowledge Center - strcasecmp() — 大/小文字を区別しないストリングの比較
  • ^ IBM Knowledge Center - strncasecmp() — 大/小文字を区別しないストリングの比較
  • ^ _stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l | MSDN
  • ^ _strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l | MSDN
  • 関連項目[編集]

    外部リンク[編集]

  • 編集

  • https://ja.wikipedia.org/w/index.php?title=Strcmp&oldid=100554724

    : 
    C
    : 


     



     2024530 () 14:50 UTC

     -















    Cookie





    Wikimedia Foundation
    Powered by MediaWiki