l**n 发帖数: 88 | 1 1. 25 horses , five lanes, how many times you need to run to pick up the 3rd
fast horse?
2. How do you debug the program if you have a bug in the program.
3. malloc memories through a function foo and free it in the main function. |
m*****f 发帖数: 1243 | 2 请问fuction foo的定义? 可以返回malloc申请空间的地址吗
谢谢分享 |
m******9 发帖数: 968 | 3 对呀,对于第3题,能不能再解释的详细一点呢?谢谢 |
l**n 发帖数: 88 | |
a*****p 发帖数: 189 | 5 void foo(void **p); //use p to return the allocated memory, should work. |
c*****o 发帖数: 178 | 6 第3题可不可以用global variable呢?
int* input;
static void Foo(int);
int _tmain(int argc, _TCHAR* argv[])
{
int size = 100;
try{
Foo(size);
::free(input);
cout<<"free memory in Main function"<
}
catch(exception &e){
cout<
}
return 0;
}
void Foo(int size){
try{
input = (int*)(::malloc(size));
cout<<"allocate " <
}
catch(exception &e){
cout< |