
#define 常量名 常量值
宏常量不可修改
const 数据类型 常变量名=常变量值
常变量不可修改
sizeof(数据类型/变量名)
整型short 2
int 4
long 4
longlong 8
单精度
float f1=3.14f
浮点数默认为double 不加f会多一道double转换成float
float变量值默认加f
双精度
double 变量名=变量值
char 字符变量名=单引号 字符变量内容 单引号
char ch='a'
**输出字符的ASCII码:强转int型
(int)ch
或者
int(ch)
注意:
1.char是字符型,其变量需要加单引号而不是双引号
2.char单字符型的内容只有一个字符
法1:C风格
char 变量名[]=“字符串值”
char str[]="hello world"
变量名后要加[],字符串值外要加双引号
法1:C++风格
#include
string str="hello"
要先引用string库,字符串值外要加双引号
bool 变量名=变量值
为bool类型变量赋值时所有非0值均为True,0为false
换行符
n
制表符
t
默认为前部分+空格一共为八位
如
aaaathelloworld
aathelloworld
aaaaaa/thelloworld
结果为
aaaa(4个空格)helloworld
aa(6个空格)helloworld
aaaaaa(2个空格)helloworld
反斜杠
\
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)