考虑函数原型void test(int a,int b=7,char z=‘*’),下面的函数调用中,属于不合法调用的是()。
A.test(5);
B.test(5,8);
C.test(6,’#’);
D.test(0,0,’x’);
A.test(5);
B.test(5,8);
C.test(6,’#’);
D.test(0,0,’x’);
A.*ff(int[],int)
B.int(*ff)(int*a,int)
C.void(*ff)(int*a,int)
D.void*ff(int*a,int)
回答下面的问题(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 函数会有什么样的结果?
A.void f(int&) const;
B.const A * f(const int );
C.A& f(int, int=50);
D.A f(const int&) const;
以下代码有什么问题?
struct Test
{
Test(int ) {}
Test() {}
void fun() {}
};
void main(void )
{
Test a(1);
a.fun();
Test b();
53
b.fun();
}
试题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:
void GetMemory(char **p, int num )
{
*p = (char *) malloc(num );
}
void Test(void )
{
char *str = NULL;
GetMemory(&str, 100 );
strcpy(str, "hello" );
printf(str );
A.0
B.1
C.2
D.4
. char *GetMemory(void) { char p[] = "hello world"; return p; } void Test(void) { char *str = NULL; str = GetMemory(); 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 函数会有什么样的结果?
根据线程安全的相关知识,分析以下代码,当调用test方法时i10时是否会引起死锁并简要说明理由。
public void test(int i)
{
lock(this)
{
if (i10)
{
i--;
test(i);
}
}
}