We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题:给定指针 p,你能知道它是否指向了一个合法的对象吗?如果能,叙述判断的思路;如果不能,也请说明原因。
我的看法: 把 if(p) 放在 try 中 , 当程序块顺利执行时,表示p指向了合法的对象;当程序块出错跳转到catch语句时,表示p没有指向合法的对象。
if(p)
try
答案思路来源- 牛客网 https://m.nowcoder.com/questionTerminal?uuid=3c218c5306324eaf9de45a74932f0b9e
The text was updated successfully, but these errors were encountered:
这个解法应该是有前提:指针初始化为NULL/0,否则if(p)其实等价于 if (p!=0),并不能判断是否指向合法对象。
Sorry, something went wrong.
No branches or pull requests
原题:给定指针 p,你能知道它是否指向了一个合法的对象吗?如果能,叙述判断的思路;如果不能,也请说明原因。
我的看法: 把
if(p)
放在try
中 , 当程序块顺利执行时,表示p指向了合法的对象;当程序块出错跳转到catch语句时,表示p没有指向合法的对象。答案思路来源- 牛客网
https://m.nowcoder.com/questionTerminal?uuid=3c218c5306324eaf9de45a74932f0b9e
The text was updated successfully, but these errors were encountered: