this is how I define struct.
struct urlFormat
{
int port;
char *host;
char *path;
int cat;
char *status;
};
this is how I initialize strcut and allocate the space for the pointer.
struct urlFormat *res;
res = malloc(sizeof(struct urlFormat));
when I used memcpy() function, it reported segmentation fault.
char *ptr1 = (char *)url;
int len = strlen(ptr1);
memcpy(res->host, ptr1, len);
I don't know how to solve it.
hostto point to; you have only allocated memory for thestruct.