  | 
≫  | 
 | 
  
 | 
    
      | 
    
    
    
     
HP OpenVMS HP C ランタイム・ライブラリ・リファレンス・マニュアル (下巻)
  
 
  
 指定された文字列の中のワイド文字の最後のオカレンスをスキャンします。
 
 
形式
#include <wchar.h>
wchar_t *wcsrchr (const wchar_t *wstr, wchar_t 
wc);
 
  関数バリアント
wcsrchr関数は,それぞれ 32 ビットと 64 ビットのポインタ・サイズで使用するための
_wcsrchr32と
_wcsrchr64という名前のバリアントを持っています。ポインタ・サイズ固有の関数の使用方法については,『HP C ランタイム・ライブラリ・リファレンス・マニュアル(上巻)』第 1.9 節を参照してください。
 
引数
 
 wstrnull で終了するワイド文字列へのポインタ。
 
 wc
wchar_t型の文字。
 
 
説明
wcsrchr関数は,null で終了するワイド文字列の中の,指定されたワイド文字の最後のオカレンスのアドレスを返します。終端の null 文字は文字列の一部と見なされます。
wcschrも参照してください。
  
 
戻り値
 
| x
 | 
指定されたワイド文字の最後のオカレンスのアドレス。
 | 
 
| NULL
 | 
ワイド文字が文字列に含まれていないことを示します。
 | 
 
 
  
 
例
 
 
#include <stdlib.h> 
#include <stdio.h> 
#include <wchar.h> 
#include <string.h> 
 
#define BUFF_SIZE 50 
#define STRING_SIZE 6 
 
main() 
{ 
    int i; 
    wchar_t s1buf[BUFF_SIZE], 
            w_string[STRING_SIZE]; 
    wchar_t *status; 
    wchar_t *pbuf = s1buf; 
 
    /* Initialize the buffer */ 
 
    if (mbstowcs(s1buf, "hijklabcdefg ytuhijklfedcba", BUFF_SIZE) 
 
        == (size_t)-1) { 
 
        perror("mbstowcs"); 
        exit(EXIT_FAILURE); 
    } 
 
    /* Initialize the string to be searched for */ 
 
 
    if (mbstowcs(w_string, "hijkl", STRING_SIZE) == (size_t)-1) { 
 
        perror("mbstowcs"); 
        exit(EXIT_FAILURE); 
   } 
 
/* This program checks the wcsrchr function by searching for */ 
/* the last occurrence of a string in the buffer s1buf and   */ 
/* prints out the contents of s1buff from the location of 
/* the string found.                                         */ 
 
    status = wcsrchr(s1buf, w_string[0]); 
/* Check for pointer to start of rightmost character string. */ 
    if (status == pbuf) { 
        printf("Error in wcsrchr\n"); 
        exit(EXIT_FAILURE); 
    } 
 
    printf("Program completed successfully\n"); 
    printf("String found : [%S]\n", status); 
 
} 
 |  
 
 この例のプログラムを実行すると,次の結果が生成されます。
 
 
 
Program completed successfully 
String found : [hijklfedcba] 
 
 |  
 
  
 
 
      |