[c/c++] programming之路(3)、转义字符及内存
一、转义字符
#include<stdio.h>
void main(){
printf("hello \nworld\a");// \n换行 \a机器响一声
getchar();//等待
}
#include<stdio.h>
void main(){
//printf("hello world");
putchar('h');
putchar('e');
putchar('l');
putchar('l');
putchar('o');
putchar('\n');//转义字符也是一个字符
putchar('w');
getchar();
}
#include<stdio.h>
void main1(){
while() putchar('\a');
putchar('A');//输出一个字符
putchar('\n');//换行
getchar();
}
void main(){
//printf("\\");//只有一个“\”会报错
//putchar('\\');
//printf("\"");
putchar('\'');
getchar();
}
二、hello world的N种做法
#include<stdio.h>
void hello1(){
printf("hello world");
}
void hello2(){
printf("A%sB","hello world");//hello world取代%s
}
void hello3(){
printf("%c%c%",'h','e');
}
void hello4(){
putchar('h');
putchar('e');
}
void hello5(){
putchar();//ASCLL码
putchar();
}
void notepad(){//练习:用ascll码打印notepad
putchar();
putchar();
putchar();
putchar();
putchar();
putchar();
putchar();
}
void hello6(){//按照8进制输出helloworld
putchar();//前面带0表示8进制
putchar();
putchar();
putchar();
}
void hello7(){//按照16进制输出helloworld
putchar(0x68);//前面带0x表示16进制
putchar(0x65);
putchar(0x6c);
putchar(0x6c);
}
void hello8(){//按照8进制输出helloworld
putchar('\150');//8进制的150所标志的字符
putchar('\145');// '\ddd',3位八进制代表的字符
putchar('\154');
putchar('\154');
}
void hello9(){//按照16进制输出helloworld
putchar('\x68');// '\xhh',16进制数据转换成编号,查找字符
putchar('\x65');
putchar('\x6c');
putchar('\x6c');
}
void hello10(){
puts("hello world");
}
void main(){
hello10();
getchar();
}
三、打开程序的n种做法
#include<stdio.h>
#include<stdlib.h> void main(){
//char str[50]="notepad";
char str[];
//sprintf(str,"%s%s","note","pad");
//sprintf(str,"%s","notepad");
//sprintf(str,"%c%c%c%c",'c','a','l','c');
//sprintf(str,"%c%c%c%c",99,97,108,99);
//sprintf(str,"%c%c%c%c",0143,0141,0154,0143);//8进制
//sprintf(str,"%c%c%c%c",0x63,0x61,0x6c,0x63);//16进制
//sprintf(str,"%c%c%c%c",'\143','\141','\154','\143');//8进制
sprintf(str,"%c%c%c%c",'\x63','\x61','\x6c','\x63');//16进制 printf(str);
system(str);//执行指令
system("pause");//暂停
}
四、通过内存地址改变变量的值

首先设置断点,进行调试

到达第一个断点时,打印出num变量的地址,根据地址查看到该地址存储的值为01

到达第二个断点,值变成了03

到达第三个断点,值变成了05,对其进行修改,将05改成59


16进制的59就等于10进制的89,最终打印出修改后的89,而非之前的5,这就是外挂改血量改蓝改攻击力的原理(找到需要修改数据的地址,然后对其进行修改)
五、加法改值



03改成09


六、打开多个程序


有的编译器一定要把变量的定义放在最前面,而不能随时定义
char str[50];这条语句需要放在前面声明
[c/c++] programming之路(3)、转义字符及内存的更多相关文章
- [c/c++] programming之路(31)、位运算(二)
一.取反的高级用法 #include<stdio.h> #include<stdlib.h> //取反的作用:末位清零 取反适用于各种位数不同的数据 void main0(){ ...
- [c/c++] programming之路(30)、位运算(一)
一.取反 ~ #include<stdio.h> #include<stdlib.h> void main(){ unsigned ; //0000 1111 char的单位是 ...
- [c/c++] programming之路(29)、阶段答疑
一.指针不等于地址 指针不仅有地址,还有类型,是一个存储了地址的变量,可以改变指向:而地址是一个常量 #include<stdio.h> #include<stdlib.h> ...
- [c/c++] programming之路(28)、结构体存储和内存对齐+枚举类型+typedef+深拷贝和浅拷贝
一.结构体存储 #include<stdio.h> #include<stdlib.h> struct info{ char c; //1 2 4 8 double num; ...
- [c/c++] programming之路(27)、union共用体
共用体时刻只有一个变量,结构体变量同时并存 一.创建共用体的三种形式 #include<stdio.h> #include<stdlib.h> #include<stri ...
- [c/c++] programming之路(26)、结构体
一.初始化字符串 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include&l ...
- [c/c++] programming之路(25)、字符串(六)——memset,Unicode及宽字符,strset
一.memset #include<stdio.h> #include<stdlib.h> #include<memory.h> void *mymemset(vo ...
- [c/c++] programming之路(24)、字符串(五)——字符串插入,字符串转整数,删除字符,密码验证,注意事项
1.将字符串插入到某位置(原字符串“hello yincheng hello cpp hello linux”,查找cpp,找到后在cpp的后面插入字符串“hello c”) 需要用到strstr字符 ...
- [c/c++] programming之路(23)、字符串(四)——strncat,atoi,strcmp,strlen等,以及常用内存函数
一.strncat及自行封装实现 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #i ...
随机推荐
- list异常
可能定义的时候没有初始化把 private List<Msg> msgList = new ArrayList<>(); 为啥我android老是忘了new ArrayList
- shell基础:数值运算与运算符
linux的shell中,变量的类型默认都是字符串型. export将aa声明为环境变量.也可用declare声明.其实就是改变了-x属性 $(()) 最常用.
- gitlab4.0_工程提交
一,环境 gitlab linux系统 IP :10.2.177.31 ==>(我已经申请了一个账户 A@A) 客户端 windows系统 IP:10.2.256. ...
- LA 3890 Most Distant Point from the Sea(半平面交)
Most Distant Point from the Sea [题目链接]Most Distant Point from the Sea [题目类型]半平面交 &题解: 蓝书279 二分答案 ...
- Python记录4:文件操作
###文件 ''' 1. 什麽是文件 文件是操作系統為用戶/应用程序提供一種操作硬盤的虚拟单位 2. 爲何要用文件 为了存取硬盘数据 3. 如何用文件 #1. 打開文件 #2. 读写文 ...
- Support For C++11/14/17 Features (Modern C++)
Visual Studio编译器对 C++11 特性的支持 具体参考网址:https://msdn.microsoft.com/en-us/library/hh567368.aspx 截至目前为止,V ...
- 16. 3Sum Closest(双指针)
Given an array nums of n integers and an integer target, find three integers in nums such that the s ...
- html5-label标签
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- 从零开始学习cocoStudio(1)--cocoStudio是什么?
一.cocoStudio是什么? CocoStudio是一套专业的永久免费的游戏开发工具集,帮助开发者快速创建游戏资源,将大部分繁琐的游戏开发工作使用编辑器来快速制作,CocoStudio包含了游戏开 ...
- 【2017-03-02】C#函数,递归法
函数 函数的意义:独立完成某项功能的个体 函数的优势:1.提高代码的重用性 2.提高功能开发的效率 3.提高程序代码的可维护性 函数四要素: 1,输入:(值的类型+名称) 2,输出:ret ...