- 1、本文档共70页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
VC笔试题大全VC笔试题大全
1.实现双向链表删除一个节点P,在节点P后插入一个节点,写出这两个函数。
2.写一个函数,将其中的\t都转换成4个空格。
3.Windows程序的入口是哪里?写出Windows消息机制的流程。
4.如何定义和实现一个类的成员函数为回调函数?
5.C++里面是不是所有的动作都是main()引起的?如果不是,请举例。
6.C++里面如何声明const void f(void)函数为C程序中的库函数?
7.下列哪两个是等同的
int b;
A const int* a = amp;b;
B const* int a = amp;b;
C const int* const a = amp;b;
D int const* const a = amp;b;
8.内联函数在编译时是否做参数类型检查?
一、请填写BOOL , float, 指针变量 与“零值”比较的 if 语句。(10分)
提示:这里“零值”可以是0, 0.0 , FALSE或者“空指针”。例如 int 变量 n
与“零值”比较的 if 语句为:
if ( n == 0 )
if ( n != 0 )
以此类推。
请写出 BOOL flag 与“零值”比较的 if 语句:
请写出 float x 与“零值”比较的 if 语句:
请写出 char *p 与“零值”比较的 if 语句:
二、以下为Windows NT下的32位C++程序,请计算sizeof的值(10分)
char str[] = “Hello” ;
char *p = str ;
int n = 10;
请计算
sizeof (str ) =
sizeof ( p ) =
sizeof ( n ) = void Func ( char str[100])
{
请计算
sizeof( str ) =
}
void *p = malloc( 100 );
请计算
sizeof ( p ) =
三、简答题(25分)
1、头文件中的 ifndef/define/endif 干什么用?
2、#include 和 #include “filename.h” 有什么区别?
3、const 有什么用途?(请至少说明两种)
4、在C++ 程序中调用被 C编译器编译后的函数,为什么要加 extern “C”声明?
5、请简述以下两个for循环的优缺点
// 第一个
for (i=0; i
{
if (condition)
DoSomething();
else
DoOtherthing();
} // 第二个
if (condition)
{
for (i=0; i
DoSomething();
}
else
{
for (i=0; 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(str, 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);
其中
文档评论(0)