Why scanf(“%s”,&str); behaves as scanf(“%s”,str);? [duplicate]

心已入冬 提交于 2019-12-06 03:21:14

The two pointer values (str and &str) have the same binary value, namely the address of str. They do, however, have different types: When passed as an argument, str is converted to type char *, while &str has type char (*)[80]. The former is correct, while the latter is incorrect. It works, but you are using an incorrect pointer type, and in fact gcc warns about the incorrect argument type to scanf.

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