diff options
Diffstat (limited to 'memchr.c')
-rw-r--r-- | memchr.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/memchr.c b/memchr.c new file mode 100644 index 0000000..ec05235 --- /dev/null +++ b/memchr.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <string.h> + +int main() +{ + char *ptr; + char str[] = "test"; + + ptr = memchr(str ,'s', strlen(str)); + if (ptr != NULL) { + printf("文字「s」の場所: %ld\n", ptr - str + 1); + } else { + printf("文字「s」は見つかりませんでした。\n"); + } + // => 文字「s」の場所: 3 +} |