本文介绍了这段代码实际上做了什么?<指向所需指针的指针>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我不明白**<变量名在做什么> 另外声明q =& t是什么意思 #include< iostream.h> #include< conio.h> void main() { clrscr(); int x [] = { 10 , 20 , 30 , 40 , 50 }; int * p,** q,* t; p = x; t = x + 1; q =& t; cout<< * p<< ,<< * * q<< ,<< * t ++; getch(); } 我的尝试: 由turbo C4和代码块13.12给出的程序输出是10,30,20我试图理解,据我所知,输出应该是10,20,20。解决方案 正如 ppolymorphe 指出的那样,这是 C 编程语言的一个微妙之处('继承'由 C ++ :-))。 如果你打破违规行 Quote: cout<< * p<<,<< ** q<<,<< * t ++; cout<< * p<< ,<< ** q<< ,; cout<< * t ++; 然后你得到你期望的输出。 这是因为喂食物品的评估顺序 cout 是不可预测的(例如,参见评估顺序 - cppreference.com [ ^ ])。 该程序正在完成它应该做的事情。 你的问题是学习C语法的所有细微之处。 如果您不理解某些内容,请学习调试器并使用它来查看代码正在执行的操作。 谷歌使用Turbo C ++调试给出60数百万的答案,你应该在那里找到快乐。 在IDE或独立应用程序中。 Borland Turbo调试器 - 维基百科,免费的百科全书 [ ^ ] I don't understand what **<variable name is doing>Also what does statement "q=&t" means#include<iostream.h>#include<conio.h>void main() { clrscr(); int x[]={10,20,30,40,50}; int *p,**q,*t; p=x; t=x+1; q=&t; cout <<*p<<","<<**q<<","<<*t++; getch(); }What I have tried:The output of the programme given by turbo C4 and codeblocks 13.12 is 10,30,20 I tried to understand and according to me the output should be 10,20,20. 解决方案 As ppolymorphe pointed out, that is a subtlety of the C programming language ('inherited' by C++ :-) ).If you break the offending lineQuote:cout <<*p<<","<<**q<<","<<*t++;in two onescout << *p << "," << **q << ",";cout << *t++;then you get the output you expect.That happens because the order of evaluation of the items feeding cout is not predictable (see, for instance Order of evaluation - cppreference.com[^]).The program is doing exactly what it is supposed to.Your problem is learning all subtleties of C syntax.If you don't understand something, learn the debugger and use it to see exactly what the code is doing.Google with "Turbo C++ debug" gives 60 millions answers, you should find happiness there.either in IDE or as standalone app.Borland Turbo Debugger - Wikipedia, the free encyclopedia[^] 这篇关于这段代码实际上做了什么?<指向所需指针的指针>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!