本帖最后由 and001 于 2013-8-19 11:49 编辑
存在如下一个赋值问题:
我的目的是将一个4位数分别单独转换成数字显示出来:
方法一:
char i=1;
unsigned ring_lengther[2]={2023,6723};
unsigned ring_lengther;
unsinged k2,
ring_lengther=ring_length;
k2= ring_length/1000;
k3=ring_length%1000/100;
k4=ring_length%100/10;
k5=ring_length%10;
运行最后显示的是: 0000
方法二:
char i=1;
unsigned ring_length[2]={2023,6723};
unsigned ring_lengther;
unsinged k2,
ring_lengther=ring_length;
k2= ring_lengther/1000;
k3=ring_lengther%1000/100;
k4=ring_lengther%100/10;
k5=ring_lengther%10;
运行最后显示的是:K2=6 K3=7 K4=2 K5=3
请弄过的朋友解释下为啥方法一得不到所需要的结果?!
各抒己见!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
ring_lengther是unsigned short变量
怎么赋值?
应该是
unsigned short * ring_lengther;
ring_lengther = ring_length;
k2= *ring_lengther/1000;
一周热门 更多>