XINU
Functions
strchr.c File Reference

指定された文字を文字列から探し、最初にに見つかった位置をポインタで返す。 More...

Go to the source code of this file.

Functions

char * strchr (const char *s, int c)
 指定された文字を文字列から探し、最初にに見つかった位置をポインタで返す。 More...
 

Detailed Description

指定された文字を文字列から探し、最初にに見つかった位置をポインタで返す。

Definition in file strchr.c.

Function Documentation

◆ strchr()

char* strchr ( const char *  s,
int  c 
)

指定された文字を文字列から探し、最初にに見つかった位置をポインタで返す。

Parameters
[in]s探索対象の文字列
[in]c検索文字
Returns
文字cが見つかった場合は文字cが最初に登場した位置を示すポインタ、
文字cが見つからなかった場合はNULLを返す。

Definition at line 13 of file strchr.c.

14 {
15  for (; *s != '\0'; s++)
16  {
17  if (*s == (const char)c)
18  {
19  return (char *)s;
20  }
21  }
22 
23  if ((const char)c == *s)
24  {
25  return (char *)s;
26  }
27 
28  return 0;
29 }