diff options
Diffstat (limited to 'memcpy.c')
-rw-r--r-- | memcpy.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/memcpy.c b/memcpy.c new file mode 100644 index 0000000..2131ef6 --- /dev/null +++ b/memcpy.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <string.h> + +int main() +{ + char str1[10] = "Hi johnny"; + char str2[10] = {0}; + if (memcpy(str2, str1, strlen(str1))) { + printf("コピー元: %s\nコピー先: %s\n", str1, str2); + // コピー元: Hi johnny + // コピー先: Hi johnny + } else { + fprintf(stderr, "Error while coping str1 into str2.\n"); + } +} |