当前位置:网站首页>Analysis of 8 classic C language pointer written test questions
Analysis of 8 classic C language pointer written test questions
2022-07-08 00:43:00 【real Wangyanbin】
Analysis of stylus test questions
Pen test 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;
}
// What is the result of the program ?

Pen test 2:
#include<stdio.h>
// Because I haven't learned the structure yet , The size of the structure is 20 Bytes
struct Test
{
int Num;
char *pcName;
short sDate;
char cha[2];
short sBa[4];
}*p;
// hypothesis p The value of is 0x100000. What are the values of the expressions in the following table ?
// It is known that , Structure Test The variable size of type is 20 Bytes
int main()
{
printf("%p\n", p + 0x1);
printf("%p\n", (unsigned long)p + 0x1);
printf("%p\n", (unsigned int*)p + 0x1);
return 0;
}

Pen test 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;
}
// What is the output

Pen test 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;
}

Pen test 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;
}

Pen test 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;
}

Pen test 7
#include <stdio.h>
int main()
{
char* a[] = {
"work","at","alibaba" };
char** pa = a;
pa++;
printf("%s\n", *pa);
return 0;
}

Pen test 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入门-使用LeNet在MNIST实现图像分类方法二
- 搭建ADG过程中复制报错 RMAN-03009 ORA-03113
- Lecture 1: the entry node of the link in the linked list
- Vscode software
- Four stages of sand table deduction in attack and defense drill
- 从服务器到云托管,到底经历了什么?
- 去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
- Smart regulation enters the market, where will meituan and other Internet service platforms go
- 攻防演练中沙盘推演的4个阶段
- 炒股开户怎么最方便,手机上开户安全吗
猜你喜欢

Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布

Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department

How does the markdown editor of CSDN input mathematical formulas--- Latex syntax summary

Interface test advanced interface script use - apipost (pre / post execution script)

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

8道经典C语言指针笔试题解析

Password recovery vulnerability of foreign public testing

RPA云电脑,让RPA开箱即用算力无限?

Binder核心API

2022-07-07:原本数组中都是大于0、小于等于k的数字,是一个单调不减的数组, 其中可能有相等的数字,总体趋势是递增的。 但是其中有些位置的数被替换成了0,我们需要求出所有的把0替换的方案数量:
随机推荐
韦东山第二期课程内容概要
Langchao Yunxi distributed database tracing (II) -- source code analysis
Interface test advanced interface script use - apipost (pre / post execution script)
Huawei switch s5735s-l24t4s-qa2 cannot be remotely accessed by telnet
Development of a horse tourism website (optimization of servlet)
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
NVIDIA Jetson测试安装yolox过程记录
去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
51与蓝牙模块通讯,51驱动蓝牙APP点灯
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
丸子官网小程序配置教程来了(附详细步骤)
Notice on organizing the second round of the Southwest Division (Sichuan) of the 2021-2022 National Youth electronic information intelligent innovation competition
Is Zhou Hongyi, 52, still young?
Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
Kubernetes static pod (static POD)
接口测试进阶接口脚本使用—apipost(预/后执行脚本)
C language 001: download, install, create the first C project and execute the first C language program of CodeBlocks
LeetCode刷题
RPA cloud computer, let RPA out of the box with unlimited computing power?
5g NR system messages