如何取字符的ASCII值? 我想得到"中"的ascii值,不知道有没有这样的函数?请指教,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 just read the value of the bytes how do you want to use it? #include "stdafx.h"#include "stdio.h"#include "string.h"void main(){ unsigned char szString[] = "中"; for (unsigned int i=0;i<strlen((char*)szString);i++) { printf("%02x ",szString[i]); }}/*程序运行结果:d6 d0*/ char w[3] = "我";short *p;p = (short *)w;CString msg;msg.Format("%d",*p);AfxMessageBox(msg);the anwser is -11570; to denis95(denis95) : 谢谢你写的代码,d6d0正是我想要的结果,不过我想把d6d0赋给一个变量,请问有什么办法? unsigned char szString[] = "中";int iRes = 0; for (unsigned int i=0;i<strlen((char*)szString);i++) { iRes = iRes<<8 + szString[i]; }... 各位可能不太明白我的意思。现重新说明如下: CString str="中"; int i=0xd6d0; 其中i 是 str的ascii值(0xd6是"中"前一半的ascii值,0xd0是"中"后一半的ascii值) 那么现在有什么办法能实现从str到i 的转换呢? 即i=func(str),各位知不知道如何设计这个func()呢?非常感谢! 试试这个函数int atoi( const char *string ); CString str("中国人"); char ch[10]; memset(byt,0,10); for(int i=0;i<str.GetLength();i++) ch[i]=str.GetAt(i); 上面是得到char数组。以下可以得到int型: CString str("中国人"); int myint[10]; memset(byt,0,10); for(int i=0;i<str.GetLength();i++) myint[i]=str.GetAt(i)&0xff; 其实everandforever(Forever)已经给出了方法了.int GiveMeIntForAChineseChar(unsigned char ChineseChar[]){ int iRes=ChineseChar[0]; iRes = iRes<<8 + ChineseChar[1]; return iRes;}void main(){ unsigned char szString[] = "中"; cout<<GiveMeIntForAChineseChar(szString)<<endl;}以上程序未经测试! 试试这段:int *p = (int*)"中";int n=*p; 关于获取网页内容的问题 请指点,多线程编程初学。这个为什么报错。。。 冷门问题:MSSOAP3.ConnectorProperty 中有 ProxyPort 属性? 有没有别的画直方图的控件,MSChart有点不能满足我的需要 钩子函数的问题,望你帮帮我! 怎么样将二维坐标转化维三维坐标?(OPenGL) 高分求vs.net下载,在线等待。MSN:[email protected] theApp的问题 画位图问题! 我用vc编了一段程序运行后。我的win2000不能注销和重启 怎样在DLL中访问SQL Server,DLL须能被ASP调用! 对话框弹出位置的问题
#include "stdio.h"
#include "string.h"
void main()
{
unsigned char szString[] = "中";
for (unsigned int i=0;i<strlen((char*)szString);i++)
{
printf("%02x ",szString[i]);
}
}/*
程序运行结果:
d6 d0
*/
short *p;
p = (short *)w;
CString msg;
msg.Format("%d",*p);
AfxMessageBox(msg);
the anwser is -11570;
谢谢你写的代码,d6d0正是我想要的结果,不过我想把d6d0赋给一个变量,
请问有什么办法?
int iRes = 0;
for (unsigned int i=0;i<strlen((char*)szString);i++)
{
iRes = iRes<<8 + szString[i];
}
...
现重新说明如下:
CString str="中";
int i=0xd6d0;
其中i 是 str的ascii值(0xd6是"中"前一半的ascii值,0xd0是"中"后一半的ascii值)
那么现在有什么办法能实现从str到i 的转换呢?
即i=func(str),各位知不知道如何设计这个func()呢?
非常感谢!
const char *string
);
char ch[10];
memset(byt,0,10); for(int i=0;i<str.GetLength();i++)
ch[i]=str.GetAt(i);
int myint[10];
memset(byt,0,10); for(int i=0;i<str.GetLength();i++)
myint[i]=str.GetAt(i)&0xff;
{
int iRes=ChineseChar[0];
iRes = iRes<<8 + ChineseChar[1];
return iRes;
}void main()
{
unsigned char szString[] = "中";
cout<<GiveMeIntForAChineseChar(szString)<<endl;
}以上程序未经测试!
int *p = (int*)"中";
int n=*p;