一、转义字符

 #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)、转义字符及内存的更多相关文章

  1. [c/c++] programming之路(31)、位运算(二)

    一.取反的高级用法 #include<stdio.h> #include<stdlib.h> //取反的作用:末位清零 取反适用于各种位数不同的数据 void main0(){ ...

  2. [c/c++] programming之路(30)、位运算(一)

    一.取反 ~ #include<stdio.h> #include<stdlib.h> void main(){ unsigned ; //0000 1111 char的单位是 ...

  3. [c/c++] programming之路(29)、阶段答疑

    一.指针不等于地址 指针不仅有地址,还有类型,是一个存储了地址的变量,可以改变指向:而地址是一个常量 #include<stdio.h> #include<stdlib.h> ...

  4. [c/c++] programming之路(28)、结构体存储和内存对齐+枚举类型+typedef+深拷贝和浅拷贝

    一.结构体存储 #include<stdio.h> #include<stdlib.h> struct info{ char c; //1 2 4 8 double num; ...

  5. [c/c++] programming之路(27)、union共用体

    共用体时刻只有一个变量,结构体变量同时并存 一.创建共用体的三种形式 #include<stdio.h> #include<stdlib.h> #include<stri ...

  6. [c/c++] programming之路(26)、结构体

    一.初始化字符串 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #include&l ...

  7. [c/c++] programming之路(25)、字符串(六)——memset,Unicode及宽字符,strset

    一.memset #include<stdio.h> #include<stdlib.h> #include<memory.h> void *mymemset(vo ...

  8. [c/c++] programming之路(24)、字符串(五)——字符串插入,字符串转整数,删除字符,密码验证,注意事项

    1.将字符串插入到某位置(原字符串“hello yincheng hello cpp hello linux”,查找cpp,找到后在cpp的后面插入字符串“hello c”) 需要用到strstr字符 ...

  9. [c/c++] programming之路(23)、字符串(四)——strncat,atoi,strcmp,strlen等,以及常用内存函数

    一.strncat及自行封装实现 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> #i ...

随机推荐

  1. Windows服务器时间不同步问题

    一台域内的服务器时间不停地被修改,我先向用户收集了一些信息 只有这一台出现此问题,其他服务器均为正常(补充一下,问题快解决完的时候用户告诉我一个重要的消息,就是时间被修改了一段时间后自动会被修改回去) ...

  2. jquery简介未完成

    jQuery jQuery是一个快速.简洁的javascript框架,是继prototype之后又一个优秀的代码库(或者javascript框架).jQuery设计的宗旨是writeLess,Do M ...

  3. Linux 配置yum源.

    Linux 配置yum源. 环境:虚拟机中安装了RedHat ,在进行安装mariadb的时候,出现如下错误.是因为yum源的问题,需要进行配置yum源.本教程是配置本地yum源. [root@loc ...

  4. react-redux 使用后台数据初始化(渲染)界面

    注:首先在redux中改变state只能通过action操作,reducers改变state 在组件中 store.js import { createStore } from "redux ...

  5. Javascript-双色球

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  6. JavaScript-判断指定日期是一年中第几天-按照从大到小的顺序输出

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. Visio 保存卡死解决办法

    右键Visio图标 属性--兼容性--以兼容模式运行这个程序 要打上对勾  且下面的系统版本要选和你电脑版本一致的选项 特权等级   以管理员身份运行次程序  要打上对勾

  8. UIView常见方法

    - (void)addSubview:(UIView *)view; 添加一个子控件view   - (void)removeFromSuperview; 从父控件中移除 - (UIView *)vi ...

  9. 【Hadoop学习之九】MapReduce案例分析一-天气

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-3.1.1 找出每个月气温最高的2天 1949 ...

  10. 【Linux学习七】软件安装

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 一.编译安装1.解压 源码文件是压缩包 要先解压tar -zxvf t ...