当前位置:网站首页>【逆向分析】C语言指针部分简单学习
【逆向分析】C语言指针部分简单学习
2022-07-21 05:08:00 【3Ss安全前线】
文章目录
C语言指针初识
& 取地址运算符
* 间接运算符
int main() {
//指针
//& 取地址运算符 &变量名
//* 间接运算符
int Number = 0;
return 0;
int main() {
//指针
//& 取地址运算符 &变量名
//* 间接运算符
int Number = 0;
printf("变量Number的值和地址是:%d,%x",Number,&Number);
return 0;
}
int main() {
//指针
//& 取地址运算符 &变量名
//* 间接运算符
int Number = 0;
int* pNum = &Number; //& 取地址赋值给篇int *指针类型的变量Num
*pNum = 5; //将取出地址处赋值
printf("变量Number的值和地址是:%d,%x",Number,&Number);
return 0;
}
void add(int * a,int * b) {
//定义*a、*b接收x、y的地址
int temp = *a + *b; //取a、b地址的值相加,也就是5+6
*a = temp; //将temp的值11赋值给a地址的值x,跳出函数
}
int main() {
int x = 5; //定义x的值为5
int y = 6; //定义y的值为6
add(&x, &y); //将x、y的地址赋给add函数
printf("%d",x); //此时x的值为6
return 0;
}
int main() {
char szStr[] = "My name is sanss"; //声明一个字符串
char* szStr1; //定义一个准备被copy的字符串
int length = (strlen(szStr) + 1); //计算szStr的长度(由于00结尾长度+1)
szStr1 = (char*)malloc(length * sizeof(char)); //申请内存
memset(szStr1,0,length); //初始化成0
strcpy(szStr1, szStr);; //拷贝
puts(szStr1); //打印
free(szStr1); //释放内存
return 0;
}
int main() {
FILE * pFile; //声明文件指针
char* szReadTextBuffer; //接收读文件的数据
int nReadFileSize; //读取的文件的字节数
int nReadRetSize; //真实返回长度
//r读取 w写出 b二进制
pFile = fopen("C:\\1.txt","rb"); //二进制读取文件
if (pFile == NULL) {
//判断是否读取到了文件,未读取到退出
printf("failed");
exit(0);
}
fseek(pFile,0,SEEK_END); //文件指针设置到末尾数
nReadFileSize = ftell(pFile); //获取文件指针位置,就可以通过末尾数指针位置获取文件长度
rewind(pFile); //文件指针复位
szReadTextBuffer = (char*)malloc((nReadFileSize * sizeof(char)) + 1); //申请一块内存用来放读取的数据
if (szReadTextBuffer == NULL) {
//判断是否申请成功
printf("failed");
exit(0);
}
memset(szReadTextBuffer,0,nReadFileSize + 1); //初始化内存
nReadRetSize = fread(szReadTextBuffer, 1, nReadFileSize, pFile); //读取文件里的数据真实长度
if (nReadRetSize != nReadFileSize) {
//判断真实长度和预设长度是否相等
printf("failed");
exit(0);
}
puts(szReadTextBuffer); //打印读取的文件内容
fclose(pFile); //关闭文件
return 0;
}
int main() {
char * szWriteBuffer = "sansssssssssssssssssssssss"; //设置写入内容
FILE * pFile; //定义文件指针
pFile = fopen("C:\\Users\\systemctl\\Desktop\\2.txt", "wb"); //设置写入文件
if (pFile == NULL) //判断文件是否可以打开
{
printf("failed!");
exit(0);
}
fwrite(szWriteBuffer,strlen(szWriteBuffer),1,pFile); //写入文件
fclose(pFile);
return 0;
}
边栏推荐
- 网页服务器/客户端搭建(nodejs启动exe程序)
- thinkphp6使用EasyWeChat5.x公众号开发(二)
- Openfoam programming: combination of VOF method and porous media model
- 通过Web代理服务器实现文本文件传输至外部服务器并且修改后返回
- Planned tasks under laravel5.1
- OpenFoam中的VOF相变方程
- PHP environment construction (recommended pagoda panel)
- Buuctf [gxyctf2019] no dolls
- 打字机打字,退格效果
- Fundamentals of computational heat transfer
猜你喜欢
The C language header stdio cannot be found after Xcode upgrade H solution
The text file is transferred to the external server through the web proxy server and returned after modification
Nodejs+Express使用 cors 中间件解决跨域问题
Nvm、Nrm使用教程
【文件上传绕过】--二次渲染
web安全--文件包含(本地包含,远程包含)
Buuctf n1book [Chapter 2 advanced web] file upload
Comsol热传导方法求解迷宫问题(路径规划)
phpmyadmin后台文件包含漏洞分析
【极客大挑战 2019】Easy,Love,Baby-SQL
随机推荐
BUUCTF [SUCTF 2019]EasySQL
PHP的魔术方法
a标签下载和window.location.herf下载
PHP handles CSV files to solve Chinese garbled code
JS将16进制颜色转为rgba格式
DVWA [SQL injection] error injection learning record
QML implements CSDN search box with irregular rounded corners
JS converts hexadecimal color to RGBA format
Thinkphp6 uses easywechat5 Development of official account of X (I)
Introduction to PHP
【漏洞复现】CVE-2022-22954 VMware Workspace ONE Access漏洞分析
Realization of interface displacement by linear Schrodinger equation
墨者学院-WebShell文件上传分析(第3-5题)
ecshop漏洞复现
BUUCTF(misc)
COMSOL heat conduction method to solve maze problem (path planning)
之前公司的转正题目之一:合并单元格
【内网渗透】内网渗透红日靶场(vulnstack)二
第二届网刃杯web题复现
Construction de l'environnement PHP (panneau de pagode recommandé)