  | 
≫  | 
 | 
  
 | 
    
      | 
    
    
    
     
HP OpenVMS HP C ランタイム・ライブラリ・リファレンス・マニュアル (下巻)
  
 
  
 
s1 がポイントしている文字列の中での, 
s2 がポイントしている文字列に含まれる文字のシーケンスの最初のオカレンスを探します。
 
 
形式
#include <string.h>
char *strstr (const char *s1, const char *s2);
 
  関数バリアント
strstr関数は,それぞれ 32 ビットと 64 ビットのポインタ・サイズで使用するための
_strstr32と
_strstr64という名前のバリアントを持っています。ポインタ・サイズ固有の関数の使用方法については,『HP C ランタイム・ライブラリ・リファレンス・マニュアル(上巻)』第 1.9 節を参照してください。
 
引数
 
 s1, s2文字列へのポインタ。
 
 
戻り値
 
| ポインタ
 | 
発見された文字列へのポインタ。
 | 
 
| NULL
 | 
文字列が発見されなかったことを示します。
 | 
 
 
  
 
例
 
 
#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 
 
main() 
{ 
    static char lookin[]="that this is a test was at the end"; 
    
    putchar('\n'); 
    printf("String: %s\n", &lookin[0] ); 
    putchar('\n'); 
    printf("Addr: %s\n", &lookin[0] ); 
    printf("this: %s\n", strstr( &lookin[0] ,"this") ); 
    printf("that: %s\n", strstr( &lookin[0] , "that" ) ); 
    printf("NULL: %s\n", strstr( &lookin[0], "" ) ); 
    printf("was: %s\n", strstr( &lookin[0], "was" ) ); 
    printf("at: %s\n", strstr( &lookin[0], "at" ) ); 
    printf("the end: %s\n", strstr( &lookin[0], "the end") ); 
    putchar('\n'); 
    
    exit(0); 
} 
 |  
 
  
この例は,次の結果を生成します。
 
 
 
$ RUN STRSTR_EXAMPLE
String: that this is a test was at the end
Addr: that this is a test was at the end
this: this is a test was at the end
that: that this is a test was at the end
NULL: that this is a test was at the end
was: was at the end
at: at this is a test was at the end
the end: the end
$ 
 
 |  
 
 
 
 
      |