今天在Linux下写代码的时候发现了一个问题,可以使用 atoi 函数将一个字符串转化为一个整型值。当我反过来转化的时候却发现没有该函数...,不是我记错了,使用itoa函数是可以将整型值转化
2019-07-04 07:29
嗨,伙计们。我有一个我无法理解的问题,我希望有一个对C更深入的知识的人比我能在这件事上有所启发。首先我用MPLAB V85和HealthCC-V7.6Lite的16F87。我知道它都是旧的,但它通常为我服务!这是问题-我需要发送命令字符串到一个LCD触摸屏显示器,以显示频率为10Hz的分辨率。整个命令字符串是pGo0.0.t1.txt=“x.xxx,xx”0xff0xff0xfff,其中x表示频率,并存储在数组FrqBuf[]中,这工作时间很好。假设从0增加10Hz的频率。一切都很好,它显示正确,直到频率从0.039990赫兹到0.040000赫兹,当垃圾显示在最后三个数字。它在400000 kHz等时是相同的。在调试模式中的单步显示,变量REM(见附加代码)从40000跳到65536,因为它试图在4之后计算第一个零。它将继续显示最后三个数字中的垃圾,直到第四个数字正确地从9翻转到零,所有的工作都在意料之中,直到下一个4出现在第四位。当第五、第六和第七位数字显示为4时,其余的数字都显示为垃圾。它可能不是最有效的,但是对我来说,它是直观的,在任何你选择的数字基础上的计算器上都可以工作。有什么线索可以帮助你吗?我希望我已经包含了足够的信息,如果不是,我相信你会告诉我。 以上来自于百度翻译 以下为原文 Hi guys. I am having a problem that I cannot understand and I was hoping that someone with a more in-depth knowledge of C than I might be able to shed some light on the matter.First off I am using a 16F887 with MPLAB v8.5 and Hi-Tech C v9.6 Lite. I know it is all old but it serves me well usually!Here is the problem - I need to send a command string to an LCD touch screen display to display frequency to a resolution of 10Hz. The entire command string is page0.t1.txt="xx.xxx,xx"0xFF 0xFF 0xFF where x denotes the frequency and is stored in the array freqbuf[] and this works fine some of the time. Let's say I increment the frequency by 10Hz steps from zero. All is well and it displays correctly until the frequency rolls over from 00.039,990 Hz to 00.040,000 Hz when rubbish is displayed in the last three digits. It is the same when it goes to 400,000 KHz and so on.Single stepping in debug mode shows that the variable rem (see attached code) jumps from 40000 to 65536 as it attempts to calculate the first zero after the 4. It will continue to display rubbish in the last three digits until the fourth digit, which behaves properly, rolls over from 9 to zero and everything works as expected until the next 4 occurs in fourth digit. It is the same when the fifth, sixth and seventh digits show 4, the remaining digits show rubbish.The routine I use for the conversion is attached. It may not be the most efficient but to me it is intuitive and works ok on a calculator in any number base you choose. Any clues that might help? I hope I have included enough information, if not I am sure you will let me know. Attachment(s)Encoder.doc (24.00 KB) - downloaded 12 times
2019-03-04 07:59
进制整数:\"); scanf(\"%d\",&i); itoa(i,str,10); printf(\"这个10进制整数是:%s\\n
2023-06-20 07:04
[]={"8"};的效果就是上面这个程序的意思,我尝试过使用itoa的函数,itoa(n,str,10);没有成功,请问应该怎么改,或者是有没有其他的方法?谢谢各位了。
2016-07-22 10:43
浮点转换成ASIII的实际方法,它和ITOA一样。我得到了ITOA方法如下,它工作良好cha*ITOA(int Valm,int Base){静态char BUF〔32〕={ 0 };int i=30
2019-09-11 12:35
在单片机中,常用到数字与字符的方法,在C中都是使用itoa函数,C51也有这个函数,但是,8051的RAM是很有限的,所以尽量避免使用int型,常用的是unsigned char。当需要转换成字符串时用itoa的话,还是有点浪费。还是自力更生,自己写了一个,代码如
2019-07-18 17:38
我在哪里可以找到标准的C函数?.h文件??目前我正在寻找ITOA()或DTOSTRE()或类似的东西。我看了CyLib,h和Cytul。h,但是运气不好。谢谢 以上来自于百度翻译 以下为原文
2019-07-25 14:01
在百度百科上看到实现 itoa 函数的源代码,里面有一行代码引起了我的兴趣
2023-07-22 10:49
嗨,这是我的代码:发生了什么:LED是1秒,关闭1秒,后5秒和关闭5秒,它循环。但是我不想在IF中写这行,但是我想写:但是当我写下这行时,LED永远不会出现在5秒……问题是什么呢?看来iToA在我
2019-03-12 15:07
怎么把 int 类型的数据转换成字符串: 看项目有用 micrilib,itoa() 函数 和 sprintf() 能不能用呢?怎么用 比如把 int a=10;转换成字符串 charbuf[]=\"10\";
2023-11-01 08:27