// 期望输出str = hello world 的两种方法 #include <stdio.h> char *GetStr(char **p) { *p = "hello word"; return *p; } int main() { char *str = NULL; if (NULL != GetStr(&str)) { printf(" str = %s\n",str); } return 0; }
</pre><pre name="code" class="cpp"><img src="http://img.blog.csdn.net/20150511210800602?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhcWlhbjU1Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /> #include <stdio.h> char *GetStr(char *p) { p = "hello word"; return p; } int main() { char *str = NULL; if (NULL != GetStr(str)) { printf(" str = %s\n", str = GetStr(str)); } return 0; }
时间: 2024-11-10 14:26:06