【发布时间】:2015-12-30 04:14:50
【问题描述】:
我有一个字符串,我使用 strtok 将其分解为多个片段
d.dtype = strtok(incoming.mtext, "|");
d.threshold= strtok(NULL, "|");
d.pid = strtok(NULL, "|");
使用
printf("device type %s\n", d.dtype);
printf("device threshold %s\n", d.threshold);
printf("device pid %s\n", d.pid);
我可以看到所有内容都已正确分配。
然后我正在发送一条外发消息,我的消息结构是
struct msg_st {
long int mtype;
char mtext[BUFSIZ];
};
struct msg_st outgoing;
如何将d.pid 值复制到我的outgoing.mtype 中?
【问题讨论】:
-
outgoing.mtype = strtol(d.pid, NULL, 10);
标签: c pointers copy message-queue