当前位置:网站首页>8道经典C语言指针笔试题解析
8道经典C语言指针笔试题解析
2022-07-07 22:51:00 【real Wangyanbin】
笔试题1:
#include<stdio.h>
int main()
{
int a[5] = {
1, 2, 3, 4, 5 };
int *ptr = (int *)(&a + 1);
printf( "%d,%d", *(a + 1), *(ptr - 1));
return 0;
}
//程序的结果是什么?
笔试题2:
#include<stdio.h>
//由于还没学习结构体,这里告知结构体的大小是20个字节
struct Test
{
int Num;
char *pcName;
short sDate;
char cha[2];
short sBa[4];
}*p;
//假设p 的值为0x100000。 如下表表达式的值分别为多少?
//已知,结构体Test类型的变量大小是20个字节
int main()
{
printf("%p\n", p + 0x1);
printf("%p\n", (unsigned long)p + 0x1);
printf("%p\n", (unsigned int*)p + 0x1);
return 0;
}
笔试题3
#include<stdio.h>
int main()
{
int a[4] = {
1, 2, 3, 4 };
int* ptr1 = (int*)(&a + 1);
int* ptr2 = (int*)((int)a + 1);
printf("%x,%x", ptr1[-1], *ptr2);
return 0;
}
//输出结果是多少
笔试题4
#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;
}
笔试题5
#include<stdio.h>
int main()
{
int a[5][5];
int(*p)[4];
p = a;
printf( "%p,%d\n", &p[4][2] - &a[4][2], &p[4][2] - &a[4][2]);
return 0;
}
笔试题6
#include<stdio.h>
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,%d", *(ptr1 - 1), *(ptr2 - 1));
return 0;
}
笔试题7
#include <stdio.h>
int main()
{
char* a[] = {
"work","at","alibaba" };
char** pa = a;
pa++;
printf("%s\n", *pa);
return 0;
}
笔试题8:
#include<stdio.h>
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;
}
边栏推荐
- Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
- 测试流程不完善,又遇到不积极的开发怎么办?
- 3 years of experience, can't you get 20K for the interview and test post? Such a hole?
- 【测试面试题】页面很卡的原因分析及解决方案
- 动态库基本原理和使用方法,-fPIC 选项的来龙去脉
- 【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
- fabulous! How does idea open multiple projects in a single window?
- Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
- 玩转Sonar
- 接口测试进阶接口脚本使用—apipost(预/后执行脚本)
猜你喜欢
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
【笔记】常见组合滤波电路
Service Mesh介绍,Istio概述
redis你到底懂不懂之list
玩轉Sonar
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
接口测试进阶接口脚本使用—apipost(预/后执行脚本)
Detailed explanation of interview questions: the history of blood and tears in implementing distributed locks with redis
paddle一个由三个卷积层组成的网络完成cifar10数据集的图像分类任务
2022-07-07:原本数组中都是大于0、小于等于k的数字,是一个单调不减的数组, 其中可能有相等的数字,总体趋势是递增的。 但是其中有些位置的数被替换成了0,我们需要求出所有的把0替换的方案数量:
随机推荐
5g NR system messages
Solution to the problem of unserialize3 in the advanced web area of the attack and defense world
How does the markdown editor of CSDN input mathematical formulas--- Latex syntax summary
Deep dive kotlin collaboration (the end of 23): sharedflow and stateflow
Vscode software
CoinDesk评波场去中心化进程:让人们看到互联网的未来
ABAP ALV LVC template
Is it safe to open an account on the official website of Huatai Securities?
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
Service Mesh的基本模式
去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
[programming problem] [scratch Level 2] December 2019 flying birds
What if the testing process is not perfect and the development is not active?
商品的设计等整个生命周期,都可以将其纳入到产业互联网的范畴内
攻防演练中沙盘推演的4个阶段
Development of a horse tourism website (realization of login, registration and exit function)
Stm32f1 and stm32cubeide programming example - rotary encoder drive
Notice on organizing the second round of the Southwest Division (Sichuan) of the 2021-2022 National Youth electronic information intelligent innovation competition