[ZLG-ARM] LM中使用字符串遇到的问题

[复制链接]
1577|1
 楼主| MWEN 发表于 2008-4-23 10:47 | 显示全部楼层 |阅读模式
void&nbsp;f1(char&nbsp;str1[],&nbsp;char&nbsp;str2[])<br />{<br />&nbsp;uint8&nbsp;i=0;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;while(str2!='\0')<br />&nbsp;{<br />&nbsp;str1=str2;<br />&nbsp;i++;<br />&nbsp;}<br />}<br /><br />void&nbsp;f2(char&nbsp;*str1,&nbsp;char&nbsp;*str2)<br />{<br />&nbsp;for&nbsp;(;*str2!='\0';str1++,str2++)<br />&nbsp;&nbsp;&nbsp;*str1&nbsp;=&nbsp;*str2;&nbsp;&nbsp;&nbsp;//不会将str2的复制到str1<br />}<br /><br />void&nbsp;StrProcess(void)<br />{<br />&nbsp;//char&nbsp;s1[]=&quot;1234567890&quot;;<br />&nbsp;//char&nbsp;s2[]=&quot;4000&quot;;<br />&nbsp;char&nbsp;*s1=&quot;1234567890&quot;;<br />&nbsp;char&nbsp;*s2=&quot;4000&quot;;<br /><br />&nbsp;f1(s1,s2);<br />&nbsp;//f2(s1,s2);<br />}<br /><br />开发环境:LM615,KEIL&nbsp;MDK3.05<br /><br />如果采用数组的方式,S1的数据会改变为&quot;4000567890&quot;<br />如果采用字符串指针的方式,则S1的数据不会改变。<br />不知是什么原因?
zlgarm 发表于 2008-4-23 11:36 | 显示全部楼层

Re

MWEN&nbsp;&nbsp;您好:<br />请您移到ZLG-MCU版面或www.zlgmcu.com.cn的Luminary版面。<br />On&nbsp;duty&nbsp;:liuzhaofu
您需要登录后才可以回帖 登录 | 注册

本版积分规则

35

主题

44

帖子

0

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