当前位置:网站首页>指针经典笔试题
指针经典笔试题
2022-07-06 05:12:00 【云朵c】
笔试题一
int main()
{
int a[5] = {
1,2,3,4,5 };
int* ptr = (int*)(&a + 1);
printf("%d\n", *(a + 1));
printf("%d\n", *(ptr - 1));
return 0;
}
//程序的结果是什么?
笔试题二
//结构体的大小是20个字节
struct Test
{
int Num;
char *pcName;
short sDate;
char cha[2];
short sBa[4];
}*p;
//假设p的值为0x100000。 如下表表达式的值分别为多少?
int main()
{
printf("%p\n", p + 0x1);
printf("%p\n", (unsigned long)p + 0x1);
printf("%p\n", (unsigned int*)p + 0x1);
return 0;
}
笔试题三
int main()
{
int a[4] = {
1, 2, 3, 4 };
int *ptr1 = (int *)(&a + 1);
int *ptr2 = (int *)((int)a + 1);
printf("%x\n", ptr1[-1]);
printf("%x\n", *ptr2);
return 0;
}
笔试题四
#include <stdio.h>
int main()
{
int a[3][2] = {
(0, 1), (2, 3), (4, 5) };
int *p;
p = a[0];
printf( "%d", p[0]);
return 0;
}
笔试题五
int main()
{
int a[5][5];
int(*p)[4];
p = a;
printf("%p\n", &p[4][2] - &a[4][2]);
printf("%d\n", &p[4][2] - &a[4][2]);
return 0;
}
笔试题六
int main()
{
int aa[2][5] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int* ptr1 = (int*)(&aa + 1);
int* ptr2 = (int*)(*(aa + 1));
printf("%d\n", *(ptr1 - 1));
printf("%d\n", *(ptr2 - 1));
return 0;
}
笔试题七
#include <stdio.h>
int main()
{
char *a[] = {
"work","at","alibaba"};
char**pa = a;
pa++;
printf("%s\n", *pa);
return 0;
}
笔试题八
int main()
{
char *c[] = {
"ENTER","NEW","POINT","FIRST"};
char**cp[] = {
c+3,c+2,c+1,c};
char***cpp = cp;
printf("%s\n", **++cpp);
printf("%s\n", *--*++cpp+3);
printf("%s\n", *cpp[-2]+3);
printf("%s\n", cpp[-1][-1]+1);
return 0;
}
边栏推荐
- RT thread analysis log system RT_ Kprintf analysis
- yolov5 tensorrt加速
- [leetcode daily question] number of enclaves
- Drive development - the first helloddk
- Three methods of Oracle two table Association update
- Knowledge points of circular structure
- 从0到1建设智能灰度数据体系:以vivo游戏中心为例
- MySQL time processing
- Mongodb basic knowledge summary
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
猜你喜欢
Weng Kai C language third week 3.1 punch in
Extension of graph theory
Hyperledger Fabric2. Some basic concepts of X (1)
GAMES202-WebGL中shader的编译和连接(了解向)
Rce code and Command Execution Vulnerability
Nacos - TC Construction of High available seata (02)
Postman manage test cases
Compilation and connection of shader in games202 webgl (learn from)
趋势前沿 | 达摩院语音 AI 最新技术大全
acwing周赛58
随机推荐
Oracle query table index, unique constraint, field
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
[NOIP2009 普及组] 分数线划定
Upload nestjs configuration files, configure the use of middleware and pipelines
Three methods of Oracle two table Association update
驱动开发——HelloWDM驱动
内核判断i2c地址上是否挂载外设
Nacos TC setup of highly available Seata (02)
趋势前沿 | 达摩院语音 AI 最新技术大全
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
Please wait while Jenkins is getting ready to work
[lgr-109] Luogu may race II & windy round 6
C# AES对字符串进行加密
Summary of redis AOF and RDB knowledge points
Project manager, can you draw prototypes? Does the project manager need to do product design?
Postman pre script - global variables and environment variables
Why does MySQL need two-phase commit
ByteDance program yuan teaches you how to brush algorithm questions: I'm not afraid of the interviewer tearing the code
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
nacos-高可用seata之TC搭建(02)