关于char()的问题请教.

tinyghost 2003-11-13 11:58:45
请问char(27),char(67),char(15)是什么意思.char(int)怎么定义.
...全文
55 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jdsnhan 2003-11-13
  • 打赏
  • 举报
回复
一种字符的表示方法。
klbt 2003-11-13
  • 打赏
  • 举报
回复
使用方法:
String ls_str

ls_str = char(27)
mittee 2003-11-13
  • 打赏
  • 举报
回复
ASCII -> string 用 char(n)
string -> ASCII 用asc(string)
iamxia 2003-11-13
  • 打赏
  • 举报
回复
n是对应的ASCII十进制码,你可以对照ASCII表查看一下
workhand 2003-11-13
  • 打赏
  • 举报
回复
相当于一个字符,例如如果‘A’的码为88,则char(88)就是字符‘A’。这个对应关系可以找找书
wyhgg 2003-11-13
  • 打赏
  • 举报
回复
This example sets ls_S to an asterisk, the character corresponding to the ASCII value 42:
string ls_S
ls_S = Char(42)

in database:
Char(10) char 10: char length
njjianguogu 2003-11-13
  • 打赏
  • 举报
回复
定義為字符串,
字符的個數
再次简化代码,取消串口,直接显示结果,仍然有问题!!

疑问代码如下:
struct _USB_DATA_STRUCT
{
/*
unsigned char command_data[40];//release结果正确
int command_index;
int command_size;
int numofnod;
*/
int command_index;
int command_size;
int numofnod;
unsigned char command_data[40];//release结果错误

void SetData(unsigned char* pdata,int size)
{
if(size>40)
{
AfxMessageBox("数据太大,超范围!");
return;
}
memcpy(command_data,pdata,size);
}
};

void CTestprjDlg::OnButton1()
{
// TODO: Add your control notification handler code here
unsigned char ctem[32];//错误:32,103,104; 正确:105,110

USB_DATA_STRUCT CommandData;//需要填写要发送的数据

ctem[0]=0xee;
ctem[1]=0x01;
memset(ctem+2,0x00,30);

CommandData.SetData(ctem,32);

ShowTest(CommandData.command_data,32);
}

void CTestprjDlg::ShowTest(unsigned char* p,int nlen)
{
CString str = _T("");
for(int i=0;i <32;i++)
{
CString tmp_str;
tmp_str.Format("0x%02X ", p[i]);
str += tmp_str;
}
m_textctrl.SetWindowText(str);
}

//VC6

Debug版本没有问题,输出如:
EE 01 00 00 00...后面全0
Release版本(按Maximize speed优化)有问题,输出如:
EE 01 00 00 00 00 00 00 00 00 00 00 EE 01 00 00 00 00 00 00 00 00 00 00 EE 01 00 00 00 00 00 00

Release版本下,按以下修改没有问题
1.调整ctem的大小。小于等于104有问题,大于等于105没有问题
2.将ctem改为char* ctem;
ctem=new char[32];
没有问题

3.优化方式由Maximize speed修改为Minimize code也没问题

请教可能是什么原因?

1,079

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧