当前位置:网站首页>Pointer classic written test questions
Pointer classic written test questions
2022-07-06 05:13:00 【Cloud C】
List of articles
Written test question 1
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;
}
// What is the result of the program ?


Question 2 of the written examination
// 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 ?
int main()
{
printf("%p\n", p + 0x1);
printf("%p\n", (unsigned long)p + 0x1);
printf("%p\n", (unsigned int*)p + 0x1);
return 0;
}


Written test question 3
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;
}


Written test question 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;
}


Written test question five
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;
}


Written test question six
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;
}


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


Written test question 8
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;
}


边栏推荐
猜你喜欢

Codeforces Round #804 (Div. 2)

趋势前沿 | 达摩院语音 AI 最新技术大全

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

Hyperledger Fabric2. Some basic concepts of X (1)

Codeforces Round #804 (Div. 2)
![[leetcode daily question] number of enclaves](/img/6e/1da0fa5c7d1489ba555e4791e2ac97.jpg)
[leetcode daily question] number of enclaves

Ora-01779: the column corresponding to the non key value saving table cannot be modified
![[effective Objective-C] - memory management](/img/1e/611aa998486bbac76ac103c3091794.jpg)
[effective Objective-C] - memory management

Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?

Principle and performance analysis of lepton lossless compression
随机推荐
The IPO of mesk Electronics was terminated: Henan assets, which was once intended to raise 800 million yuan, was a shareholder
Why does MySQL need two-phase commit
Basic knowledge and examples of binary tree
Summary of three log knowledge points of MySQL
CUDA11.1在线安装
Modbus protocol communication exception
Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
Set detailed map + interview questions
Idea one key guide package
组播和广播的知识点梳理
C# AES对字符串进行加密
Request (request object) and response (response object)
Postman前置脚本-全局变量和环境变量
Vite configures the development environment and production environment
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
GAMES202-WebGL中shader的编译和连接(了解向)
EditorUtility. The role and application of setdirty in untiy
从0到1建设智能灰度数据体系:以vivo游戏中心为例
Postman关联
[buuctf.reverse] 159_ [watevrCTF 2019]Watshell