summaryrefslogtreecommitdiff
path: root/memcpy.c
blob: 2131ef61ccb2e998c5f555deba290c1b0c6a0855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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");
  }
}