29 lines
621 B
C
29 lines
621 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
char buf[] = {
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
};
|
|
|
|
char *buf2 = malloc(sizeof(buf));
|
|
memcpy(buf2, buf, sizeof(buf));
|
|
|
|
for (size_t i = 0; i < sizeof(buf2); i++) {
|
|
if (buf[i] != buf2[i]) {
|
|
printf("buf[%zu] != buf2[%zu] !!\n", i, i);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
printf("copy ok.\n");
|
|
free(buf2);
|
|
return 0;
|
|
}
|