笔试题循环

时间:2024-04-29 11:52:13 笔试 我要投稿

辉景求职网给大家分享关于笔试题循环的范文,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。。

笔试题循环

笔试题(循环)

三、简答题(25分)
1、头文件中的 ifndef/define/endif 干什么用?
2、#include %26<filename.h%26> 和
#include "filename.h" 有什么区别?
3、const 有什么用途?(请至少说明两种)
4、在C++ 程序中调用被 C编译器编译后的函数,
为什么要加 extern "C"声明?
5、请简述以下两个for循环的优缺点
// 第一个for (i=0; i%26<N; i++)
{if (condition)
DoSomething();
else
DoOtherthing();}
优点:缺点:
// 第二个if (condition)
{for (i=0; i%26<N; i++)
DoSomething();}
else{
for (i=0; i%26<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);
}
请问运行Test函数会有什么样的结果?答:
Void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(%26str, 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函数会有什么样的结果?答:
五、编写strcpy函数(10分)
已知strcpy函数的原型是
char *strcpy(char *strDest, const char *strSrc);
其中strDest是目的字符串,strSrc是源字符串。
(1)不调用C++/C的字符串库函数,请编写函数 strcpy
(2)strcpy能把strSrc的内容复制到strDest,为什么还要char * 类型的返回值?

以上笔试题循环的内容,由辉景求职网(mingnadm.com)-搜集整理分享。

【笔试】相关文章:

广本笔试04-29

笔试题循环04-29

公卫助理执业医师笔试练习题04-28

笔试的种类04-28

北京中考笔试成绩与实验考核占重比例04-28

建设银行笔试知识04-28

中国铝业笔试04-28

我的求职之旅以及笔试,面试心得总结--from工大后院01-29

最火爆的笔试攻略----校园招聘求职笔试攻略01-29

本人求职笔试面试经验分享开篇01-29