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


边栏推荐
- ByteDance program yuan teaches you how to brush algorithm questions: I'm not afraid of the interviewer tearing the code
- 你需要知道的 TCP 三次握手
- Nacos TC setup of highly available Seata (02)
- Why does MySQL need two-phase commit
- Nacos - TC Construction of High available seata (02)
- 驱动开发——HelloWDM驱动
- 从0到1建设智能灰度数据体系:以vivo游戏中心为例
- Class inheritance in yyds dry inventory C
- Implementing fuzzy query with dataframe
- On the solution of es8316's audio burst
猜你喜欢
![[leetcode16] the sum of the nearest three numbers (double pointer)](/img/99/a167b0fe2962dd0b5fccd2d9280052.jpg)
[leetcode16] the sum of the nearest three numbers (double pointer)

ISP learning (2)
![[classic example] binary tree recursive structure classic topic collection @ binary tree](/img/39/0319c4be43716f927b9d98d89f7655.jpg)
[classic example] binary tree recursive structure classic topic collection @ binary tree

趋势前沿 | 达摩院语音 AI 最新技术大全

Postman pre script - global variables and environment variables

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

Excel转换为Lua的配置文件

Class inheritance in yyds dry inventory C

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

CUDA11.1在线安装
随机推荐
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
[leetcode daily question] number of enclaves
IPv6 comprehensive experiment
Vite configures the development environment and production environment
The kernel determines whether peripherals are attached to the I2C address
Flody的应用
C AES encrypts strings
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
[leetcode16] the sum of the nearest three numbers (double pointer)
The underlying structure of five data types in redis
麦斯克电子IPO被终止:曾拟募资8亿 河南资产是股东
[noip2008 improvement group] stupid monkey
Postman断言
图数据库ONgDB Release v-1.0.3
Request (request object) and response (response object)
[mask requirements of OSPF and Isis in multi access network]
MySQL if and ifnull use
[NOIP2008 提高组] 笨小猴
TCP three handshakes you need to know
[leetcode] 18. Sum of four numbers