对于循环方向(新手) [英] For loop direction (newbie)

查看:89
本文介绍了对于循环方向(新手)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用一个简单的for循环撕掉我的头发!


为什么这段代码有效:

I''m tearing my hair out over a simple for loop!

Why does this code work:

展开 | 选择 | Wrap | 行号

推荐答案

定义不起作用。


通过查看它而突出的是你有行的东西。定义为一个字符,但在for循环中,你使用它就像它是一个整数。为什么?你是故意这样做的吗?这就是问题。


如果你需要ascii表示(''char''),那么在你将整数值传递给你传递给它的任何函数之后那么,把它转换为char形式。


你基本上第一个幸运。
the thing that stands out just by looking at it is that you have "line" defined as a character, but in the for loop, you use it like it''s an integer. Why? Are you doing that intentionally? That''s the problem.

IF you need the ascii representation ( the ''char'' ), then after you pass the integer value to whatever function you''re passing it to, THEN convert it to char form.

You''re basically getting lucky with the first one.


一个字符是8位无符号整数值,在PIC程序中大量使用以节省空间。当你只有300字节的RAM时,这很重要!
A char is an 8 bit unsigned integer value, used a lot in PIC programs to save space. When you only have 300 bytes of RAM, it matters!


这篇关于对于循环方向(新手)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆