[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 ...
随机推荐
- Dart- move html element
今天给出一个例程,像是个小游戏!哈哈 一 html //anagram.html <!DOCTYPE HTML> <html> <head> <title&g ...
- 单点登录开源架构之CAS
服务端 开源地址:https://github.com/apereo/cas Release版:https://github.com/apereo/cas/releases Windows下使用下载c ...
- cocos2d-js 遮挡层(禁止触摸事件传递层)
在游戏中,我们经常会碰到一些弹窗,这些弹窗禁止点透,也就是禁止触摸事件传递到底层,我们称之为遮挡层,这些遮挡层,需要开发遮挡层,我们首先得了解cocos2d-js的触摸传递机制,本文主要针对cocos ...
- Selenium基础知识(四)表单切换
在测试过程中,经常会碰到frame和iframe,嵌套等情况 这种情况下直接通过id,name等等是无法定位到的 好在selenium替我们想到了这个问题switch_to方法解决问题 switch_ ...
- shell编程:case语句
- maven pom文件报错:Multiple annotations found at this line 解决方案(转)
研究maven多模块项目时,因为家里和公司不能同时开发,所以把家里搭建好的项目复制到公司继续研究, 当时家里的电脑搭建好项目之后是没问题的,但是复制到公司的eclipse上之后就看到pom文件出现下面 ...
- DX9 顶点缓存案例
// @time 2012.3.5 // @author jadeshu //包含头文件 #include <Windows.h> #include <d3d9.h> #pra ...
- jQuery安装
http://www.runoob.com/jquery/jquery-install.html 网页中添加jQuery: 方法一:可以从http://jquery.com/download/ 下载j ...
- 【Redis学习之六】Redis数据类型:集合和有序集合
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 redis-2.8.18 一.集合 Set无序的.去重的元素 ...
- maven 核心概念
1). 项目构建过程中的各个环节 . 清理 . 编译 . 测试 . 报告 . 打包 . 安装 . 部署 2). 配置环境变量 . 配置 JDK 配置 JAVA_HOME + PATH maven 需要 ...