应该不会错位吧
char 和 unsigned char变量都只占一个字节的啊
【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: 标 题: Re: fileheader转化失败
: 发信站: 牧场物语 (Sat May 8 08:35:15 2004)
: 转信站: COA!news.happynet.org!maily.cic.tsinghua.edu.cn!news.bylinux.net!Stanfo
:
: struct userec1 { /* Structure used to hold information in */
: char userid[IDLEN + 2]; /* PASSFILE */
: char flags[2];
: time_t firstlogin;
: char lasthost[16];
: unsigned int numlogins;
: unsigned int numposts;
:
:
: struct userec2 { /* Structure used to hold information in */
: char userid[IDLEN + 2]; /* PASSFILE */
: char flags; /*一些标志,戒网,版面排序之类的 */
: unsigned char title; /*用户级别 */
: time_t firstlogin;
: char lasthost[16];
: unsigned int numlogins;
: unsigned int numposts;
:
: 仔细看看这里直接memcpy userec1->userec2 会有什么后果。
:
: 【 在 F1yingFish@smth.org-SPAM.no (F.Fish|人生如梦·我心依旧) 的大作中提到: 】
: : 应该要加上
: : bhnew.flags = bh.flags[0];
: : bhnew.title = 0;
: : 吧
: : 【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: : : 我ft,这样一搞不就全乱套了嘛!当然要一项一项依次赋值了。你那个结构好前面
: : : 就多了一个title项,memcpy了当然就后面的项全都错位了。
: : ※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
:
:
: --
:
: ※ 来源:·牧场物语 bbs.stanford.edu·[FROM: FARM]
--
FROM 219.224.195.142