当使用printf的时候想区别字符型和字符串型
格式字符:c---字符形式
格式字符:s---字符串形式
#include <stdio.h>
int main()
{
char cChar1='6';
char cChar2='8';
printf("%c%c\n",cChar1,cChar2);//字符型变量
return 0;
}
notice:字符型变量用‘’!!!!and字符串型用“”!!!!!
(tomato字符串型和字符型不能同时用char,nnd一直报错)
输出字符型A和整型A的值
分别对字符型和整型的A赋值,观察两者转换
#include <stdio.h>
int main()
{
char cChar1;
char cChar2;
int iInt1;
int iInt2;
cChar1 = 'a';
cChar2 = 57;
iInt1 = 'a';
iInt2 = 99;
printf("%c\n", cChar1);
printf("%c\n", cChar2);
printf("%d\n",iInt1);
printf("%d\n",iInt2);
return 0;
}
hehe,ASCII码表不知道97是a,字符串型57是9。。。。
常用的转义字符and其含义
\n 回车换行 ASC值:10
\b 退格 ASC:13
\r 回车ASC:12
\’ 单引号符ASC:39
忘记带书了!!!!