char str[]={"FuJian"};print("%d",trlen(tr));该程序段的运行结果是()。
A.9
B.7
C.6
D.8
A.9
B.7
C.6
D.8
请问以下代码有什么问题:
int main()
{
char a;
char *str=&a;
strcpy(str,"hello");
printf(str);
return 0;
}
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
试题6:
void GetMemory(char **p, int num )
{
*p = (char *) malloc(num );
}
void Test(void )
{
char *str = NULL;
GetMemory(&str, 100 );
strcpy(str, "hello" );
printf(str );
回答下面的问题(6分) (1).Void GetMemory(char **p, int num) { *p = (char *)malloc(num); } void Test(void) { char *str = NULL; GetMemory(&str, 100); strcpy(str, "hello"); printf(str); } 请问运行Test 函数会有什么样的结果?
. void Test(void) { char *str = (char *) malloc(100); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “world”); printf(str); } } 请问运行Test 函数会有什么样的结果?
下列程序在32位linux或unix中的结果是什么?
func(char *str)
{
printf(" %d",sizeof(str));
printf(" %d",strlen(str));
}
main()
{
char a[]="123456789";
printf(" %d",sizeof(a));
printf(" %d",strlen(a));
func(a);
}
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
试题6:
void GetMemory(char **p, int num )
{
*p = (char *) malloc(num );
}
void Test(void )
{
char *str = NULL;
GetMemory(&str, 100 );
strcpy(str, "hello" );
printf(str );
}
试题4:
void GetMemory(char *p )
{
p = (char *) malloc(100 );
}
void Test(void )
{
char *str = NULL;
GetMemory(str );
strcpy(str, "hello world" );
printf(str );
}
试题5:
char *GetMemory(void )
{
char p[] = "hello world";
return p;
}
void Test(void )
{
char *str = NULL;
str = GetMemory();
printf(str );
}
分析下面的程序:
void GetMemory(char **p,int num)
{
*p=(char *)malloc(num);
}
int main()
{
char *str=NULL;
GetMemory(&str,100);
strcpy(str,"hello");
free(str);
if(str!=NULL)
{
strcpy(str,"world");
}
printf("\n str is %s",str);
getchar();
}
问输出结果是什么?希望大家能说说原因,先谢谢了