当前位置:网站首页>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;
}
边栏推荐
- Zhou Hongqi, 52 ans, est - il encore jeune?
- [programming problem] [scratch Level 2] March 2019 draw a square spiral
- Introduction to paddle - using lenet to realize image classification method I in MNIST
- Coindesk comments on the decentralization process of the wave field: let people see the future of the Internet
- paddle入门-使用LeNet在MNIST实现图像分类方法二
- 52岁的周鸿祎,还年轻吗?
- [programming problem] [scratch Level 2] December 2019 flying birds
- Basic principle and usage of dynamic library, -fpic option context
- redis你到底懂不懂之list
- 【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
猜你喜欢
Reentrantlock fair lock source code Chapter 0
[programming problem] [scratch Level 2] draw ten squares in December 2019
取消select的默认样式的向下箭头和设置select默认字样
腾讯安全发布《BOT管理白皮书》|解读BOT攻击,探索防护之道
How to measure whether the product is "just needed, high frequency, pain points"
51 communicates with the Bluetooth module, and 51 drives the Bluetooth app to light up
“一个优秀程序员可抵五个普通程序员”,差距就在这7个关键点
Play sonar
接口测试进阶接口脚本使用—apipost(预/后执行脚本)
[basis of recommendation system] sampling and construction of positive and negative samples
随机推荐
How to measure whether the product is "just needed, high frequency, pain points"
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
The standby database has been delayed. Check that the MRP is wait_ for_ Log, apply after restarting MRP_ Log but wait again later_ for_ log
【测试面试题】页面很卡的原因分析及解决方案
【obs】官方是配置USE_GPU_PRIORITY 效果为TRUE的
2022-07-07:原本数组中都是大于0、小于等于k的数字,是一个单调不减的数组, 其中可能有相等的数字,总体趋势是递增的。 但是其中有些位置的数被替换成了0,我们需要求出所有的把0替换的方案数量:
Which securities company has a low, safe and reliable account opening commission
他们齐聚 2022 ECUG Con,只为「中国技术力量」
手写一个模拟的ReentrantLock
[question de programmation] [scratch niveau 2] oiseaux volants en décembre 2019
华为交换机S5735S-L24T4S-QA2无法telnet远程访问
某马旅游网站开发(登录注册退出功能的实现)
Development of a horse tourism website (optimization of servlet)
韦东山第三期课程内容概要
The underlying principles and templates of new and delete
When creating body middleware, express Is there any difference between setting extended to true and false in urlencoded?
new和delete的底层原理以及模板
[programming problem] [scratch Level 2] December 2019 flying birds
v-for遍历元素样式失效
Trust orbtk development issues 2022