当然有准备作弊,例如在中创建上下文,temp是指向结构数据而不是结构节点的指针。 - 哦,要成为Blobel! Is it possible that struct node is defined slightly differently, as struct node{struct data *next;} *temp;If not then it can''t be done without some kind of cheating, asclearly anything accesses by temp will be a pointer. There is, of course, ready cheating, such as creating a context inwhich temp is a pointer to a struct data instead of a struct node.--Oh, to be a Blobel! 所以你说的是临时是一个指向会员数据的指针s? 没有便携式解决方案,因为无法确定 使用的填充量对于结构成员。您可以通过 来做猜测: void * v = temp; v - = sizeof(char)+ sizeof (float)+ sizeof(int); struct data * d = v; 但这只有在结构没有填充的情况下才有效,这是一个无效的假设。 也许另一种可能性是: struct data d; void * dp =& d; void * s =& ds; int diff = s - dp; void * v = tmp; v - = diff; struct data * answer = v; 即便如此,你可能还有一些特定于平台的问题。 Jon ---- 学习使用Linux汇编语言的程序 http://www.cafeshops.com/bartlettpublish .8640017 不,他不是这么说的。他可能_meant_,因为没有一些 暗示这个谜题是无法解决的,但他没有说出来。 没有便携式解决方案,因为那里无法确定用于结构构件的填充量。 No, he isn''t saying that. He probably _meant_ that, since without somehint of that ilk the puzzle is unsolvable, but he didn''t say it. There is no portable solution, as there is no way to determine the amount of padding used for structure members. 是的,对于已知的声明结构:offsetof。 (不,我不再提供任何提示。) Richard Yes, there is, for a known, declared structure: offsetof. (No, I''m not giving any more hints.) Richard 这篇关于链接列表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 12:18