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


边栏推荐
- 用StopWatch 统计代码耗时
- 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
- Imperial cms7.5 imitation "D9 download station" software application download website source code
- Postman pre script - global variables and environment variables
- [mathematical modeling] differential equation -- sustainable development of fishing industry
- Driver development - hellowdm driver
- Postman test report
- Flink kakfa data read and write to Hudi
- Acwing week 58
- MySQL time processing
猜你喜欢
![[leetcode] 18. Sum of four numbers](/img/06/c160b47d756290e5474e4c07e68648.png)
[leetcode] 18. Sum of four numbers

Steady, 35K, byte business data analysis post

Idea one key guide package

MPLS experiment

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

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

SQL injection vulnerability (MSSQL injection)

Postman前置脚本-全局变量和环境变量

Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
随机推荐
Why does MySQL need two-phase commit
Configuration file converted from Excel to Lua
ISP learning (2)
SQL injection vulnerability (MSSQL injection)
Flink kakfa data read and write to Hudi
In 2022, we must enter the big factory as soon as possible
MPLS experiment
Crazy God said redis notes
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Sliding window problem review
F12 solve the problem that web pages cannot be copied
Class inheritance in yyds dry inventory C
【LGR-109】洛谷 5 月月赛 II & Windy Round 6
The video in win10 computer system does not display thumbnails
[数学建模] 微分方程--捕鱼业的持续发展
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell
What are the advantages of the industry private network over the public network? What specific requirements can be met?
Postman Association
EditorUtility.SetDirty在Untiy中的作用以及应用
flutter 实现一个有加载动画的按钮(loadingButton)