栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > C++面试题库

达内C++班Core C部分测试题

达内C++班Core C部分测试题

达内C++班Core C部分测试题

姓名:            成绩:

1. 结构体与联合体有何区别?(5分)

 

 

2. h头文件中的ifndef/define/endif 的作用?(5分)

 

3. i nclude<file.h> i nclude “file.h”的区别?(5分)

 

 

 

4. 以下为Windows NT下的32位C++程序,请计算sizeof的值(10分)

char  str[] = “Hello” ;

char   *p = str ;

int     n = 10;

请计算sizeof (str ) =     (2分)

sizeof ( p ) =      (2分)

sizeof ( n ) =      (2分)

void Func ( char str[100])

{

请计算

sizeof( str ) =        (2分)

}

void *p = malloc( 100 );

请计算

sizeof ( p ) =        (2分)

5. 分析以下程序并回答问题(5分)

void GetMemory(char *p)

{

p = (char *)malloc(100);

}

void Test(void)

{

char *str = NULL;

GetMemory(str);

 

strcpy(str, “hello world”);

printf(str);

}

请问运行Test函数会有什么样的结果?

 

 

6. 请分析以下程序输出结果:(5分)

#include<stdio.h>
main()
{
int a,b,c,d;
a=10;
b=a++;
c=++a;
d=10*a++;

printf(“b,c,d:%d,%d,%d”,b,c,d);
return 0;
}

 

7.请写出程序出出结果(5分)

main()
{
int a[5]={1,2,3,4,5};
int *ptr=(int *)(&a+1);

printf(“%d,%d”,*(a+1),*(ptr-1));
}

8.用至少两种方法将一个整数转化为其数字字符串(10分)

 

9.用程序描述冒泡排序算法,并简要叙述其原理(10分)

 

10.自己实现C风格字符串操作的三个函数int strlen(const char* s),

char* strcpy(char* dest,const char* str),

char* strcat(char* dest,const char* src);(20分)

 

 

11.简述C语言内存三大分配函数的用法?(提醒:calloc,malloc,realloc)

(10分)

12.新建文件file2.txt,将已经存在的文件file1.txt中的内容写入file2.txt当中(10分)

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/265646.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号