当前位置:网站首页>指针经典笔试题
指针经典笔试题
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;
}


边栏推荐
- GAMES202-WebGL中shader的編譯和連接(了解向)
- C# AES对字符串进行加密
- A little knowledge of CPU, disk and memory
- [mathematical modeling] differential equation -- sustainable development of fishing industry
- [noip2009 popularization group] score line delimitation
- ISP学习(2)
- 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
- GAMES202-WebGL中shader的编译和连接(了解向)
- Application of Flody
- 關於Unity Inspector上的一些常用技巧,一般用於編輯器擴展或者其他
猜你喜欢
![[untitled]](/img/7e/d0724193f2f2c8681a68bda9e08289.jpg)
[untitled]

ISP learning (2)

Codeforces Round #804 (Div. 2)

L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires

浅谈镜头滤镜的类型及作用

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

Simple understanding of interpreters and compilers

RT thread analysis - object container implementation and function

nacos-高可用seata之TC搭建(02)

Vite configures the development environment and production environment
随机推荐
EditorUtility. The role and application of setdirty in untiy
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
Postman测试报告
Extension of graph theory
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
[mask requirements of OSPF and Isis in multi access network]
[untitled]
Yolov5 tensorrt acceleration
关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
Pickle and savez_ Compressed compressed volume comparison
[mathematical modeling] differential equation -- sustainable development of fishing industry
CUDA11.1在线安装
Chip debugging of es8316 of imx8mp
Codeforces Round #804 (Div. 2)
Microblogging hot search stock selection strategy
Basic knowledge and examples of binary tree
Vite configures the development environment and production environment
TCP three handshakes you need to know
Modbus协议通信异常
JS quick start (II)