struct tftp_rrq {
short opcode;
char *req;
};
struct tftp_conn{
int type;
int sock;
char *mode;
char *fname;
char *hostname;
struct sockaddr_in addr;
socklen_t addrlen;
FILE *fp;
int blocknr;
char msgbuf[512];
};
struct tftp_rrq* p_rrq = (struct tftp_rrq *)malloc(sizeof(struct tftp_rrq));
p_rrq->req = (char *)malloc(strlen(t->fname)+strlen(t->mode)+2);
p_rrq->opcode = htons(1);
memcpy(p_rrq->req, t->fname, strlen(t->fname));
memcpy(p_rrq->req + strlen(t->fname) + 1, t->mode,
strlen(t->mode));
其中t是struct tftp_conn *t。这个是没有问题的。
p_rrq->opcode = htons(1);
memcpy(p_rrq->req, t->fname, strlen(t->fname));
memcpy(p_rrq->req + strlen(t->fname) + 1, t->mode, strlen(t->mode));
在赋值的时候出的问题。上面三句都有问题,求大神