资源描述
嵌入式软件工程师C语言笔试题
资料仅供参考
软件笔试题(A)
姓名: 学校:
专业: 电话:
(如无特殊说明,以下所有测试内容都是基于32位嵌入式系统)
1) 程序的局部变量存在于 中,全局变量存在于 中,动态申请数据存在于 中。
2) 如何用if来做零值比较
int a : if(a==0)
bool a :
float a :
void * a :
3)
void func( char str[100])
{
printf(“%d”,sizeof( str ) );
}
输出结果是:
有下列定义:
char str[] = “Hello World”;
char *p = str;
int n = 10;
void *ptr = malloc( 100 );
请写出如下表示式的值:
sizeof (str ) = ;
sizeof ( p ) = ;
sizeof ( n ) = ;
sizeof ( ptr )= ;
unsigned char *p1;
unsigned long *p2;
p1=(unsigned char *)0x87000000;
p2=(unsigned long *)0x80010000;
请问p1+5 = ;
p2+5 = ;
5) char str[10];
strcpy(str,"");
产生什么结果?为什么?
6) 用C语句,让程序跳转到绝对地址0xFFFF0去执行
7) 已知一个数组array,用一个宏定义,求出数组的元素个数
#define ARRAY_COUNT
8) 简要说明,为什么标准头文件都有类似以下的结构。
#ifndef __INC_Honeywell_Debug
#define __INC_Honeywell_Debug
#ifdef __cplusplus
extern "C" {
#endif
/*...*/
#ifdef __cplusplus
}
#endif
#endif /*__INC_Honeywell_Debug */
9) 给定结构
struct token_t
{
char digit:4;
char index:4;
unsigned short data:8;
unsigned long tick;
};
问sizeof(token_t) =
10) 在空白处填写完整强制类型转换
short (*day_p)[16];
day_p = ( ) malloc ( );
11) 简述:TCP/UDP有何区别?TCP/IP通信建立的过程怎样?端口有什么作用?
12) 找出下列嵌入式系统中断处理函数中的错误:
__interrupt double compute_area (double radius)
{
double area = PI * radius * radius;
printf(" Area = %f", area);
return area;
}
13) 请写一个宏,若处理器是Big_endian的,则返回0;若是Little_endian的,则返回1
14) 数组a[N],存放了1至N-1个自然数,其中某个自然数重复一次。写一个函数,找出被重复的数字。要求:(时间复杂度为O(N),可用一种或一种以上方法)
函数原型:
int do_dup(int a[],int N)
15) 基于如下数据结构,实现环形缓冲区的读写函数
#define BUF_SIZE (100)
typedef struct str_data_buf
{
unsigned char write_index;
unsigned char read_index;
BOOL full_flag;
BOOL empty_flag;
int data_buf[BUF_SIZE];
}data_buf_t, *p_data_buf;
static data_buf_t ring_buf;
实现其读写函数:
//----------------------------------------------------------------------------------------------
BOOL write_fifo(int new_data) /* write one item into ring buffer */
BOOL read_item (int* data) /* read one item from ring buffer */
选做部分(C++)
1) 类的静态成员和非静态成员有何区别?
2) 定义并实现String类,要求有构造函数、析构函数和赋值函数,
展开阅读全文