有以下程序 #include #include void fun ( char *s ) { char a[10]; strcpy( a, "STRING" ); s = a; } main() { char *p="PROGRAM"; fun

admin2019-12-17  26

问题 有以下程序
#include
#include
void  fun ( char  *s )
{
char  a[10];
strcpy( a, "STRING" );
s = a;
}
main()
{
char  *p="PROGRAM";
fun( p );
printf("%s\n",p);
}
程序运行后的输出结果是(此处□代表空格)

选项 A、STRING
B、STRING□□□□
C、STRING□□□
D、PROGRAM

答案D

解析 本题考查字符串指针作为函数参数,本题中p作为字符串指针传入fun中,p指向的内容并没有发生变化,所以选项D正确。
转载请注明原文地址:https://kaotiyun.com/show/BmCp777K
0

最新回复(0)