char *memp1 = malloc(10);
char *memp2 = malloc(10);
memp1 = memp2;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct memstrc {
int k;
int b;
char *p;
};
int main(void)
{
char *hp = "hello world";
struct memstrc *memp = (struct memstrc *)malloc (sizeof(struct memstrc));
memp->p = malloc(64);
memcpy (memp->p, hp, strlen(hp));
*(memp->p + strlen(hp)) = '\0';
printf ("%s\n", memp->p);
//free (memp->p);
free (memp);
return (0);
}
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |