试题3:void test3(char* str1){char string[10];if(strlen(str1 ) <= 10 ){strcpy(string,
试题3:
void test3(char* str1)
{
char string[10];
if(strlen(str1 ) <= 10 )
{
strcpy(string, str1 );
}
}
试题3:
void test3(char* str1)
{
char string[10];
if(strlen(str1 ) <= 10 )
{
strcpy(string, str1 );
}
}
下面代码有什么问题?
Void test3(char* str1)
{
char string[10];
if(strlen(str1)<=10)
{
strcpy(string, str1);
}
}
找错
Void test1()
{
char string[10];
char* str1="0123456789";
strcpy(string, str1);
}
Void test2()
{
char string[10], str1[10];
for(I=0; I<10;I++)
{
str1[i] ='a';
}
strcpy(string, str1);
}
Void test3(char* str1)
{
char string[10];
if(strlen(str1)<=10)
{
strcpy(string, str1);
}
}
试题5:
char *GetMemory(void )
{
char p[] = "hello world";
return p;
}
void Test(void )
{
char *str = NULL;
str = GetMemory();
printf(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 );
}
试题7:
void Test(void )
{
char *str = (char *) malloc(100 );
strcpy(str, "hello" );
free(str );
... //省略的其它语句
}
找错题
试题1:
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy(string, str1 );
}
试题5:
char *GetMemory(void )
{
char p[] = "hello world";
return p;
}
void Test(void )
{
char *str = NULL;
str = GetMemory();
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 );
}
试题4:
void GetMemory(char *p )
{
p = (char *) malloc(100 );
}
void Test(void )
{
char *str = NULL;
GetMemory(str );
strcpy(str, "hello world" );
printf(str );
}