嵌入式工程师综合笔试题之指针和内存
嵌入式工程师综合笔试题之指针和内存
- 一维数组排序
- 一维数组反转
- 二分查找
- atoi函数实现 把字符串转换成整型数.
- 什么是大端和小端?写一个函数判断当前计算机是大端还是小端?通过联合体.
- 程序如下:char a[3][10] = {“hello”, {‘a’, ‘b’, ‘c’, ’d’}, “test”};
char (*p)[3][10] = &a;
char *m[3][10] = {{“hello”}, “abcd”, “test”};
(1)请用p指针分别访问字符串”test”和字符‘c’。
(2)求sizeof§,strlen((char *)p),sizeof(*p), strlen((char *)*p), sizeof(**p), strlen(**p)sizeof(m), sizeof(*m), sizeof(**m), strlen(**m)
7. 代码如下:(20分)
short c[6] = { 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8 };
char *p = (char *)( (int)(c+1) + 1 );
short (*t)[3] = &c;
*t[1] = _____ (p-1) =_________ t[0][2] = _______ (unsigned int)(p+3) - 1 = ________
8. 程序如下:short a[4] = {0xFF, 0xFEFD, 0xFC00,0xFB};
char(p)[3] = (char()[3] )( (int)&a+1 );
char *c = (char *)( (short *)&a + 1 );
计算下列表达式的按照%d输出的值:
*p[1] = _______________ ( (short)p[1] - 1 ) = __________
*(c+3) = _______________ *(short *)(c+3) - 1 = ____________
((char) (&a+1) – 4) = ____________
- 程序如下:chart = ‘a’;
char *s[4] = {“hello”, &t , “this”, “test”};
char c[4][10] = { “hello”, { ‘a’, ’b’, ’c’, ’\t’, ’0’, 0, ‘\0’, 0}, “this”, “test” };
计算下列表达式值(可能有随机或者非法):
sizeof( s ) = ______ strlen(s)= ______ sizeof( s[1] ) = ______
strlen( s[1] ) = ______ sizeof( *s[1]) = _______ strlen( *s[1] ) = ________
sizeof( c ) = ______ strlen©= ______ sizeof( c[1] ) = ______
strlen( c[1] ) = ______ sizeof( *c[1]) = _______ strlen( *c[1] ) = ________
定义变量如下:char *c[4] = {“hello”, “test”, “hahaha\n”,”this is”};
sizeof© strlen((char *)c) sizeof(c[2])
strlen(c[2]) sizeof(*c[2]) strlen(*c[2])
(1)哪些表达式有确定值?值是多少?哪些表达式是随机值或者非法表达式? (15分)
(2)如果c定义成: char c[4][10] = {“hello”, “test”, “hahaha\n”,”this is”}; 上面的值又是多少?(15分)程序如下的执行结果:
char *a[3][4];
short (*b)[3][4];
short arr[2][3][4];
short (*brr)[2][3][4];
printf(“%d %d %d %d \n”, sizeof(a), sizeof(b), sizeof(arr[0][0]), sizeof(brr[0][0]));int main()
{
int a[5] = { 0xFF,0x000000FE, 0x000000FD, 0xFC, 0xFB };
int *ptr = (int *)(&a+1);
char *c = (char *)(a+1);
printf( “%d, %d, %d, %d\n”, *(a+1), *(ptr-3) , *(c+4), *(c+5) );
return 0;
}
请问程序的打印结果?程序如下(20分):
char *a[3] = {“hello”,”test”,”hahaha”};
char **p = a;
1) 如何通过p访问到字符‘s’,写出访问表达式。
2) 计算下列表达式的值:
sizeof( a ) sizeof( *(a+0) ) sizeof( ((a+0)+1) ) sizeof( *p )程序如下的执行结果:
int main()
{
int a = 0x11223344;
short *p = (short )&a;
char (cp)[2] = (char()[2])p;
short **dp = &p;
short **ep = (short **)&a;
printf(“%x\n”,(p+1) );
printf(“%x\n”, **(cp+1) >10 );
printf(“%x\n”,**dp & 0xffff );
printf(“%p\n”, *ep );
}简述下面各声明中m的含义:
char *(*m[4])();
char *(*m)[4];
char (*m(int , int ))[4];计算下面结构体所占内存大小:(20’)
struct A struct B struct C struct D
{ { { {
char a[10]; short b; short a; char a:4;
short c; int a; char b[8]; unsigned b:4:
int b; char c[10] int c; unsigned c:8;
short d;
}; }; }; }请写出下列程序打印的结果
short a[3][4] = {{1}, {2, 3, 4}, {5, 6, 7, 8}};
short (p)[4] = (short ()[4])((int)a + 8);
printf(“%x \t %x\n”, *(p + 1), ((p + 1) - 1);
int arr[2][3] = {1, 2, 3, 4, 5, 6};
printf(“%d\n”, (int)((arr + 1) + 1) - ((int)(*arr + 1) + 1));
printf(“%d\n”, ((arr + 2) - *(*arr + 2)));int main()
{
int a = 0x11223344;
int b = 0x55667788;
short c[2][2] = {a, b};
for(i = 0;i < 4; i++)
{
printf(“%x\n”, c[i/2][i%2]);
}
return 0;
}
输出的是什么?简述下列定义:
void * ( * (fp1)(int))[10];
float ((* fp2)(int,int,int))(int);int p( int ()(int, int), int , int),
int * (m)( int ()(int, int), int, int )。
p 和m分别是什么?(10)在Linux 32bits设备上,设有以下说明和定义:
typedef union {// 共用
long i;
int k[5];
char c;
} DATE;
struct data {
int cat;
DATE cow;
double dog;
} too;
DATE max;
则语句:
printf("%d",sizeof(struct date)+sizeof(max));
的执行结果是:_____以下为Linux下的32 位C 程序,请计算sizeof 的值。
char str[] = “Hello” ;
char *p = str ;
int n = 10;
void Func( char str[100]);
void * p1 = malloc( 100 );
请计算
(1)sizeof (str ) =
(2)sizeof ( p ) =
(3)sizeof ( n ) =
(4)sizeof ( Func ) =
(5)sizeof ( p1 ) =int (*fp(int,int))( int *[2], int (*p)( char *, char *[3])) ,请分析它是什么。
画出以下代码内存图(20分):
char c = ‘a’;
char *p = &c;
char **t = &p;char *a[3] = {“hello”,”test”,”hahaha”};
char **p = a;
如何通过p访问到字符‘b’,写出访问表达式。
计算下列表达式的值:
sizeof( a ) sizeof( *(a+0) ) sizeof( ((a+0)+1) ) sizeof( *p )int **a[2][2],int (*a[2])[2]分别是什么?再简述指针的数组与数组指针分别是什么。
结构体如下:
a. sizeof( struct test )的值为多少? b. data[0]的作用是什么?
struct test{
int val;
short num;
char str[4];
char data[0];
};
c. 判断下面结构体定义各自的优缺点和使用禁忌?
struct student{
char *name;
int age;
}
struct student{
char name[10];
int age;
}
- 分析如下代码,请问每个程序运行结果及会遇到的问题:
程序一:
void GetMemory( char *p )
{
p = (char *)malloc(10);
}
void test( void )
{
char *str = NULL;
GetMemory( str );
strcpy( str, “hello”);
printf(“%s\n”, str );
}
程序二:
char *GetMemory( void )
{
char p[] = “hello”;
return p;
}
void test( void )
{
char *str = NULL;
str = GetMemory();
printf(“%s\n”, str );
}
嵌入式工程师综合笔试题之指针和内存相关推荐
- 嵌入式linux工程师 考试,嵌入式Linux工程师常见笔试题.doc
嵌入式Linux工程师常见笔试题.doc 这些年,我既参加也组织了许多这种测试,在这过程中我意识到这些测试能为带面试者和被面试者提供许多有用信息,此外,撇开面试的压力不谈,这种测试也是相当有趣的. 从 ...
- [转载] 硬件工程师经典笔试题集锦---(张飞实战电子)
[别找了全在这]硬件工程师经典笔试题集锦! 直转链接:https://www.sohu.com/a/312704438_819258 数字电路知识问题,请简要回答之. (1) 什么是 Setup和 H ...
- 嵌入式常见经典笔试题
嵌入式常见经典笔试题 2012-1-6 15:09:49 收藏 | 打印 | 投票(0) | 评论(0) | 阅读(130) ◇字体:[大 中 小] 预处理器(Preproces ...
- 计算机四级嵌入式真题,2014年3月计算机四级嵌入式工程师真题试题及答案
2014年3月计算机四级嵌入式工程师真题试题及答案 一.项选择题 1.在进行操作系统设计时,下列哪一个是构造操作系统的方法? A.网络式结构 B.并行式结构 C.微内核结构 D.主从式结构 2.在不同 ...
- 2010年3月再谈前端工程师的笔试题
最近在收集前端开发工程师的笔试题,正好看到Adam Lu.的这篇博客,感觉挺不错的转载过来! HTML && CSS 1.Doctype? 严格模式与混杂模式-如何触发这两种模式,区分 ...
- 软件开发工程师招聘笔试题面试题223套和招聘考察内容
技术族职业发展通道\阶梯\标准(即招聘考核内容) (1) 通道 技术族分为软件研发.美术.质量管理.设计.技术支持五个职业发展通道,每个发展通道包含下列职位(具体内容请见表4-技术族发展通道职位列表) ...
- 某某证券大数据开发工程师招聘笔试题
某某证券大数据开发工程师招聘笔试题 一.基础知识(单选题,每题1分,共10分) 1.实现两个远程主机之间的文件复制是用 ( D ) . A . mv B . cp C . cut D. scp 2.一 ...
- 仿真软件测试基尔霍夫定律,硬件工程师常见笔试题汇总
原标题:硬件工程师常见笔试题汇总 一.电路分析: 1.竞争与冒险 在组合逻辑中,在输入端的不同通道数字信号中经过了不同的延时,导致到达该门的时间不一致叫竞争.因此在输出端可能产生短时脉冲(尖峰脉冲)的 ...
- 2010 前端工程师的笔试题
最近在收集前端开发工程师的笔试题,正好看到Adam Lu.的这篇博客,感觉挺不错的转载过来! HTML && CSS 1.Doctype? 严格模式与混杂模式-如何触发这两种模式,区分 ...
最新文章
- 【.Net】vs2017 自带发布工具 ClickOnce发布包遇到的问题
- 这所211高校通知不放寒假!校园将实行封闭管理!
- return2libc学习笔记
- 【Python】Python 过滤列表
- 【C 语言】数据类型本质 ( sizeof 函数 | 数据类型大小 )
- 全国计算机一级考试的练题软件,2017全国计算机一级考试WPS备考练习题
- AAAI 2022 | 全身涂装式对抗纹理迷彩生成框架FCA
- V4L2应用程序框架
- java jmeter_使用Jmeter中的Java Request进行性能测试
- python 爬取贝壳网小区名称_如何使用 python 爬取全国小区名称
- centos6.5安装mysql
- cnvd与cnnvd区别_漏洞都是怎么编号的CVE/CAN/BUGTRAQ/CNCVE/CNVD/CNNVD
- mpa和pis_压力单位MPa/psi/bar之间的换算?
- JS动态添加Html
- android编译生成apk文件怎么打开,android studio生成apk在哪?
- 辛苦开发的 App 被山寨?mPaaS 帮你为 APK 上把加固锁
- 点击识别元素位置、生成显示二维码、下载二维码
- PC微信自动保存朋友圈图片
- Git原理杂谈之pull/push命令
- windows照片查看器解决方案