younger、

 

字符和字符串一些容易混淆的问题

#include<iostream>

using namespace std;

 

int main()

{

char c;

cin>>c;

char a=c-1;

int b=c-1;

cout<<c<<endl;

cout<<a<<endl;

cout<<b<<endl;

cout<<'1'<<endl;

cout<<c-1<<endl;

cout<<c-'1'<<endl;

cout<<'0'<<endl;

cout<<c-'0'<<endl;

cout<<c-0<<endl;

system("pause");

return 0;

}

输出如图:

 

#include "stdafx.h"

#include<iostream>

using namespace std;

int main()

{

int b;

b='A'+1;

cout<<b;

system("pause");

return 0;

}

输出:98

A=97,被加上单引号的A是一个阿拉伯数字,是该字符的ascll码值。

 

posted on 2013-11-20 23:40  JYoung  阅读(186)  评论(0编辑  收藏  举报

导航