ADS下关于转移符的使用!

[复制链接]
2723|7
 楼主| again_gyf 发表于 2008-6-15 15:47 | 显示全部楼层 |阅读模式
程序中使用了转义符来定义了一个数组如<br />char&nbsp;arry[]&nbsp;=&nbsp;{&quot;\xfaABC&quot;};<br />编译出错,提示C2448E:&nbsp;overlarge&nbsp;escape&nbsp;'\xfaa'&nbsp;treated&nbsp;as&nbsp;'\xaa'&nbsp;<br />请问我该怎么解决呢?哪位高手知道的话告诉我下哦!
masashinakayama 发表于 2008-6-15 16:29 | 显示全部楼层

问这种问题?

回去把C语言读上一百遍<br />还问就txjjds
 楼主| again_gyf 发表于 2008-6-15 17:35 | 显示全部楼层

请问楼上

楼上你大概没看懂我的意思<br />比如如果你想定义一个字符串数组arry<br />arry[0]&nbsp;=&nbsp;0xfa<br />arry[1]&nbsp;=&nbsp;'A'<br />arry[2]&nbsp;=&nbsp;'B'<br />......<br />那么你该怎么来定义arry呢?<br /><br />用八进制来转义可以<br />char&nbsp;arry[]&nbsp;=&nbsp;{&quot;\372ABC&quot;};<br />但为什么用16进制就不可以?
 楼主| again_gyf 发表于 2008-6-15 18:33 | 显示全部楼层

总算在IAR的帮助文档中看到说明了!

You&nbsp;can&nbsp;also&nbsp;write&nbsp;numeric&nbsp;escape&nbsp;sequences&nbsp;using&nbsp;either&nbsp;octal&nbsp;or&nbsp;hexadecimal&nbsp;digits.&nbsp;An&nbsp;octal&nbsp;escape&nbsp;sequence&nbsp;takes&nbsp;one&nbsp;of&nbsp;the&nbsp;forms:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;\d&nbsp;or&nbsp;\dd&nbsp;or&nbsp;\ddd<br />The&nbsp;escape&nbsp;sequence&nbsp;yields&nbsp;a&nbsp;code&nbsp;value&nbsp;that&nbsp;is&nbsp;the&nbsp;numeric&nbsp;value&nbsp;of&nbsp;the&nbsp;1-,&nbsp;2-,&nbsp;or&nbsp;3-digit&nbsp;octal&nbsp;number&nbsp;following&nbsp;the&nbsp;backslash&nbsp;(\).&nbsp;Each&nbsp;d&nbsp;can&nbsp;be&nbsp;any&nbsp;digit&nbsp;in&nbsp;the&nbsp;range&nbsp;0-7.<br /><br />A&nbsp;hexadecimal&nbsp;escape&nbsp;sequence&nbsp;takes&nbsp;one&nbsp;of&nbsp;the&nbsp;forms:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;\xh&nbsp;or&nbsp;\xhh&nbsp;or&nbsp;...<br />The&nbsp;escape&nbsp;sequence&nbsp;yields&nbsp;a&nbsp;code&nbsp;value&nbsp;that&nbsp;is&nbsp;the&nbsp;numeric&nbsp;value&nbsp;of&nbsp;the&nbsp;arbitrary-length&nbsp;hexadecimal&nbsp;number&nbsp;following&nbsp;the&nbsp;backslash&nbsp;(\).&nbsp;Each&nbsp;h&nbsp;can&nbsp;be&nbsp;any&nbsp;decimal&nbsp;digit&nbsp;0-9,&nbsp;or&nbsp;any&nbsp;of&nbsp;the&nbsp;letters&nbsp;a-f&nbsp;or&nbsp;A-F.&nbsp;The&nbsp;letters&nbsp;represent&nbsp;the&nbsp;digit&nbsp;values&nbsp;10-15,&nbsp;where&nbsp;either&nbsp;a&nbsp;or&nbsp;A&nbsp;has&nbsp;the&nbsp;value&nbsp;10.<br />
农民讲习所 发表于 2008-6-16 09:43 | 显示全部楼层

不是ADS中,是C标准:\x0fa,代表ascii=fa

  
xwj 发表于 2008-6-16 09:48 | 显示全部楼层

我觉得,这样混合写的话,断句很成问题

很容易产生歧义
农民讲习所 发表于 2008-6-16 10:26 | 显示全部楼层

可以用宏表示

#define&nbsp;ASCIIHEX(y)&nbsp;\x0y
Again_gyf 发表于 2008-6-17 10:54 | 显示全部楼层

re

楼上有什么好办法吗?<br />来一个字符串数组arry<br />arry[0]&nbsp;=&nbsp;0xfa<br />arry[1]&nbsp;=&nbsp;'A'<br />arry[2]&nbsp;=&nbsp;'B'<br />arry[3]&nbsp;=&nbsp;'C'<br />除了用char&nbsp;arry[]&nbsp;=&nbsp;{&quot;\372ABC&quot;}<br /><br />我觉得大家肯定会遇到这样的问题的呀,当你要写ASCII中无法打印的字符时,难道单个来吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

48

主题

630

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部