社区
单片机/工控
帖子详情
请问大家'itoa': requires ANSI-style prototy的问题
GALATEA
2012-05-23 11:22:47
我是在单片机上开发的,itoa()函数是不是在单片机上没有啊?
...全文
763
4
打赏
收藏
请问大家'itoa': requires ANSI-style prototy的问题
我是在单片机上开发的,itoa()函数是不是在单片机上没有啊?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
danagedan
2012-05-24
打赏
举报
回复
很多编译器只有atoi(字符转整数) 而没有itoa函数
我怀疑你这个编译器应该没有的 自己到软件安装目录的头文件文件夹里看看 stdlib中有没有
如果没有的话 给你推荐一段成熟的代码 直接可以用
void itoaTest(int num,char str[] )
{
int sign;
unsigned char i=0,j=0;
unsigned char temp[10];
sign=num;
do
{
temp[i] = sign%10+'0';
sign/=10;
i++;
}while(sign>0);
while(i>0)
{
str[j] = temp[i-1];
j++;
i--;
}
str[j]='\0';
}
zhangxiaopeng0829
2012-05-23
打赏
举报
回复
stdlib.h里面的itoa()是windows里面的特有功能,在类unix里面好像是用的sprintf,我如果没记错的话是这样的,至于单片机上是不是有这个功能函数,还要看你的编译器的库文件里面是否具体定义了。
net_friends
2012-05-23
打赏
举报
回复
这解释多清楚明了
dsoyy
2012-05-23
打赏
举报
回复
这个函数是C标准库里面的,你的口文件没有包含这个库自然就不会有,其实可以找到源码,自己添加函数内容啊
看看我这个,刚刚验证过了:
#include <string.h>
static void reverse (char *);
void itoa(int n, char *s)
{
int sign;
char *t = s;
if ((sign = n) < 0)
n = -n;
do
{
*s++ = n % 10 + '0';
}
while ((n /= 10) >0);
if (sign < 0)
*s++ = '-';
*s = '\0';
reverse(t);
}
void reverse(char *s)
{
int c;
char *t;
for (t = s + (strlen(s) - 1); s < t; s++, t-- )
{
c = *s;
*s = *t;
*t = c;
}
}
main()
{
char *s ;
itoa(12232,s);
printf("%s",s);
getch();
}
keil5编程中出现:MAIN.C(56): error C267: ‘UART1_SendData‘:
require
s
ANSI
-
style
pro
toty
pe,的解决方案
2、是你所编写的函数,没有放在你需要调用的地方前面,例如我需要在主函数中调用“UART1_SendData”,那么我必须把这个函数放在void main()前面,放在后面就会出现警告和显示定义不正确。#include
,或者在main.c中引用上串口的#include "uart.h"文件。经本人浏览过帖子的解决方法。
c语言编译错误c267,为啥编译出现HAHA.C(31): error C267: 'adc0832':
require
s
ANSI
-
style
pro
toty
pe.......
延迟程序:#ifndef __DELAY_H__#define __DELAY_H__#include #define uchar unsigned char#define uintunsigned intextern void _nop_ (void);/************************************************** 函数名称 ...
基于c51单片机keil报错
require
s
ansi
-
style
pro
toty
pe这个怎么解决
/****************************************************************************** * 单片机温度检测系统 *******************************************************************************/ #include <reg52.h> #include "delay.h" #include "key.h" #include "l...
warning: #223-D: function "atoi" declared implicitly
解决warning: #223-D: function "atoi" declared implicitly
问题
,atoi函数需要添加头文件#include "stdlib.h",而不是#include "math.h"。
单片机/工控
27,510
社区成员
28,796
社区内容
发帖
与我相关
我的任务
单片机/工控
硬件/嵌入开发 单片机/工控
复制链接
扫一扫
分享
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章