【发布时间】:2019-05-04 19:23:11
【问题描述】:
如何返回一个字符串以供使用? 我不知道为什么这个功能不起作用。
#include <stdio.h>
char* test(){
char A[100];
scanf("%s", A);
printf("A = %s \n", A);
return(A);
}
main(){
char* B;
B = test();
printf("B = %s \n", B); // why this return (null)?
}
【问题讨论】:
-
另外,请不要让
return看起来像一个函数。 -
为什么我的程序具有未定义行为的可能重复?