C、C++程序员应聘常见面试题(整理)_c程序员面试题

其他范文 时间:2020-02-28 09:38:55 收藏本文下载本文
【www.daodoc.com - 其他范文】

C、C++程序员应聘常见面试题(整理)由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“c程序员面试题”。

C/C++程序员应聘常见面试题

一.找错题

试题1: void test1(){ char string[10];char* str1 = “0123456789”;strcpy(string, str1);}

试题2: void test2(){ char string[10], str1[10];int i;for(i=0;i

str1[i] = 'a';} strcpy(string, str1);}

试题3:

void test3(char* str1){ char string[10];if(strlen(str1)

strcpy(string, str1);} }

试题4:

void GetMemory(char *p){ p =(char *)malloc(100);}

void Test(void){ char *str = NULL;GetMemory(str);

strcpy(str, “hello world”);printf(str);}

试题5:

char *GetMemory(void){

char p[] = “hello world”;

return p;}

void Test(void){

char *str = NULL;str = GetMemory();

printf(str);}

试题6:

void GetMemory(char **p, int num){ *p =(char *)malloc(num);}

void Test(void){ char *str = NULL;GetMemory(&str, 100);strcpy(str, “hello”);printf(str);}

试题7:

void Test(void){ char *str =(char *)malloc(100);strcpy(str, “hello”);free(str);

...//省略的其它语句 }

二.内功题

试题1:分别给出BOOL,int,float,指针变量 与“零值”比较的 if 语句(假设变量名为var)

试题2:以下为Windows NT下的32位C++程序,请计算sizeof的值 void Func(char str[100]){ sizeof(str)= ? }

void *p = malloc(100);sizeof(p)= ?

试题3:写一个“标准”宏MIN,这个宏输入两个参数并返回较小的一个。另外,当你写下面的代码时会发生什么事? least = MIN(*p++, b);试题4:为什么标准头文件都有类似以下的结构?

#ifndef __INCvxWorksh #define __INCvxWorksh #ifdef __cplusplus extern “C” { #endif /*...*/

#ifdef __cplusplus }

#endif #endif /* __INCvxWorksh */

试题5:编写一个函数,作用是把一个char组成的字符串循环右移n个。比如原来是“abcdefghi”如果n=2,移位后应该是“hiabcdefgh”

函数头是这样的:

//pStr是指向以''结尾的字符串的指针 //steps是要求移动的n

void LoopMove(char * pStr, int steps){ //请填充...}

试题6:已知WAV文件格式如下表,打开一个WAV文件,以适当的数据结构组织WAV文件头并解析WAV格式的各项信息。

WAVE文件格式说明表

偏移地址 字节数 数据类型 内 容 文件头 00H 4 Char “RIFF”标志 04H 4 int32 文件长度 08H 4 Char “WAVE”标志 0CH 4 Char “fmt”标志 10H 4 过渡字节(不定)14H 2 int16 格式类别 16H 2 int16 通道数

18H 2 int16 采样率(每秒样本数),表示每个通道的播放速度 1CH 4 int32 波形音频数据传送速率

20H 2 int16 数据块的调整数(按字节算的)22H 2 每样本的数据位数

24H 4 Char 数据标记符"data" 28H 4 int32 语音数据的长度

试题7:编写类String的构造函数、析构函数和赋值函数,已知类String的原型为:

cla String {

public:

String(const char *str = NULL);// 普通构造函数

String(const String &other);// 拷贝构造函数

~ String(void);// 析构函数

String & operate =(const String &other);// 赋值函数

private:

char *m_data;// 用于保存字符串

};试题8:请说出static和const关键字尽可能多的作用 试题9:编写一个标准strcpy函数

三.技巧题

试题1:请写一个C函数,若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1 试题2:写一个函数返回1+2+3+…+n的值(假定结果不会超过长整型变量的范围)

下载C、C++程序员应聘常见面试题(整理)word格式文档
下载C、C++程序员应聘常见面试题(整理).doc
将本文档下载到自己电脑,方便修改和收藏。
点此处下载文档

文档为doc格式

    热门文章
      整站推荐
        点击下载本文