diff options
Diffstat (limited to 'memcmp.c')
-rw-r--r-- | memcmp.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/memcmp.c b/memcmp.c new file mode 100644 index 0000000..e9ad5b7 --- /dev/null +++ b/memcmp.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <string.h> + +int main() +{ + char str1[5] = "test"; + char str2[5] = {'t', 'e', 's', 't', '\0'}; + + if (memcmp(str1, str2, 5*sizeof(char)) == 0) { + printf("str1とstr2は同じです。\n"); + } else { + printf("str1とstr2は異なります。\n"); + } + // => str1とstr2は同じです。 +} |