笔试题(循环)
三、简答题(25分)
1、头文件中的. ifndef/define/endif 干什么用?
2、#include %26lt;filename.h%26gt; 和
#include "filename.h" 有什么区别?
3、const 有什么用途?(请至少说明两种)
4、在C++ 程序中调用被 C编译器编译后的函数,
为什么要加 extern "C"声明?
5、请简述以下两个for循环的优缺点
// 第一个for (i=0; i%26lt;N; i++)
{if (condition)
DoSomething();
else
DoOtherthing();}
优点:缺点:
// 第二个if (condition)
{for (i=0; i%26lt;N; i++)
DoSomething();}
else{
for (i=0; i%26lt;N; i++) DoOtherthing();}
优点:缺点:
四、有关内存的思考题(20分)
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;GetMemory(str);
strcpy(str, "hello world");
printf(str);
}请问运行Test函数会有什么样的结果?答:
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
【笔试题(循环)】相关文章:
1.360笔试题目
2.360笔试题目