我有我拆成小块用strtok
复制整数值字符指针到局部变量用C
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);' – chux