当前位置:网站首页>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;
}

边栏推荐
- [研发人员必备]paddle 如何制作自己的数据集,并显示。
- [C language] objective questions - knowledge points
- Development of a horse tourism website (optimization of servlet)
- Reptile practice (VIII): reptile expression pack
- [programming problem] [scratch Level 2] March 2019 draw a square spiral
- LeetCode刷题
- Two small problems in creating user registration interface
- Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
- RPA云电脑,让RPA开箱即用算力无限?
- new和delete的底层原理以及模板
猜你喜欢

C # generics and performance comparison

玩轉Sonar

【obs】官方是配置USE_GPU_PRIORITY 效果为TRUE的

DNS 系列(一):为什么更新了 DNS 记录不生效?

v-for遍历元素样式失效

【笔记】常见组合滤波电路
![[the most detailed in history] statistical description of overdue days in credit](/img/f7/5c3cbfec5b010171376ac122c704b2.png)
[the most detailed in history] statistical description of overdue days in credit

redis你到底懂不懂之list

3 years of experience, can't you get 20K for the interview and test post? Such a hole?

NVIDIA Jetson测试安装yolox过程记录
随机推荐
The difference between get and post
[programming problem] [scratch Level 2] March 2019 draw a square spiral
Experience of autumn recruitment in 22 years
他们齐聚 2022 ECUG Con,只为「中国技术力量」
攻防演练中沙盘推演的4个阶段
80% of the people answered incorrectly. Does the leaf on the apple logo face left or right?
ROS from entry to mastery (IX) initial experience of visual simulation: turtlebot3
取消select的默认样式的向下箭头和设置select默认字样
How to insert highlighted code blocks in WPS and word
Deep dive kotlin synergy (XXII): flow treatment
Trust orbtk development issues 2022
手写一个模拟的ReentrantLock
深潜Kotlin协程(二十三 完结篇):SharedFlow 和 StateFlow
Jouer sonar
How does the markdown editor of CSDN input mathematical formulas--- Latex syntax summary
【GO记录】从零开始GO语言——用GO语言做一个示波器(一)GO语言基础
韦东山第二期课程内容概要
Deep dive kotlin collaboration (the end of 23): sharedflow and stateflow
The underlying principles and templates of new and delete
测试流程不完善,又遇到不积极的开发怎么办?