Under these declarations, what types are the following expressions and are they correct? [closed]

假如想象 提交于 2019-12-02 13:32:31

In the later snippet at the later part,

head -> city -> name

is wrong, because, city is not a pointer type. You need to use the dot operator (.) to access a member of a non-pointer structure variable. Just the way you've used it in

head -> next ->city.name

Other than that, syntactically, the snippets appear fine.

Just to add, as a basic sanity, you should be checking for non-NULL-ity of a pointer before de-referencing to avoid invoking undefined behavior.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!