summaryrefslogtreecommitdiff
path: root/memchr.c
diff options
context:
space:
mode:
authorhaturatu <taro@eyes4you.org>2024-12-12 19:39:56 +0900
committerhaturatu <taro@eyes4you.org>2024-12-12 19:39:56 +0900
commit9ed0c06de64b7bd6f5390c4f5972ac0578c0f858 (patch)
tree6ad61ca8f1f5a4375620313bf863a95d232d6a66 /memchr.c
parent1d810e685c5d97426bf6fe07d879a8cddd7b5743 (diff)
wip
Diffstat (limited to 'memchr.c')
-rw-r--r--memchr.c16
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
+}