刚才看了孔明的那个程序,研究了下汉字输入:
他的程序
include<stdio.h>
char s[155]=
{211,201,211,218,194,237,201,207,190,205,210,170,211,173,189,211,214,208,191,188,
199,176,215,224,161,170,161,170,187,225,191,188,163,172,210,242,180,203,206,210,
178,187,181,195,178,187,212,221,202,177,186,205,180,243,188,210,203,181,212,217,
188,251,193,203,163,172,212,218,176,203,212,194,181,189,192,180,202,177,163,172,
206,210,187,185,187,225,187,216,192,180,181,196,161,163,205,172,202,177,206,210,
187,225,212,218,191,213,207,208,202,177,188,228,185,253,192,180,191,180,191,180,
161,163,180,243,188,210,188,204,208,248,209,167,207,176,163,172,215,163,180,243,
188,210,209,167,207,176,189,248,178,189,163,161};
main(){printf("%s\n\n%75s",s,"————孙锴(卧龙孔明)");getch();}
拿第一个字为例:'由',程序里是211,201(换成16进制是D3,C9)
#include "stdio.h"
int main()
{
char a,b;
a=211;
b=201;
printf("%c%c",a,b);
getch();
return(0);
}这个输出汉字‘由’没错
再看这个
int main()
{ printf("%x",'由');
getch();
return(0);
}输出的结果却是C9D3,即201,211
为什么两种操作的顺序是相反的?
[讨论]关于C中汉字输入输出的问题