1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
int a=1;
int a2=33;
char str[512];
char str2[512];
int b;
char *c="aaaa";
char *c2="bbbb";
char d[5];
memmove(str,&a,4);
memmove(str+4,c,4);
strcpy(str2,str);
memset(str,0,strlen(str));
/*
memmove(str,&a2,4);
memmove(str+4,c2,4);
strcat(str2,str);
*/
memmove(&b,str2,4);
memmove(d,str2+4,4);
printf("str2=%d\n",b);
printf("str2=%s\n",d);
memmove(&b,str,4);
memmove(d,str+4,4);
printf("str2=%d\n",b);
printf("str2=%s\n",d);
/*
memcpy(&b,str2+8,4);
memcpy(d,str2+12,4);
printf("str2=%d\n",b);
printf("str2=%s\n",d);
*/
} |
Partager