为了账号安全,请及时绑定邮箱和手机立即绑定

请问用itoa函数在tyvj和vijos上评测为什么编译错误?

请问用itoa函数在tyvj和vijos上评测为什么编译错误?

C++
侃侃无极 2023-03-04 17:13:50
(记数问题):#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;main(){int n,i,j,tot=0,len;char x,s[8];scanf("%d %c",&n,&x);for (i=1;i<=n;i++){ itoa(i,s,10);len=strlen(s);for (j=0;j<=len-1;j++)if (s[j]==x)tot++; }printf("%d",tot);}在Dev-C++上答案正确,可是在tyvj上:评测结果#0: Compile Error (0ms, 0KiB)选手程序编译失败 Main.cpp: In function 'int main()': Main.cpp:11:15: error: 'itoa' was not declared in this scope { itoa(i,s,10); ^#1: Compile Error (0ms, 0KiB)#2: Compile Error (0ms, 0KiB)#3: Compile Error (0ms, 0KiB)#4: Compile Error (0ms, 0KiB)#5: Compile Error (0ms, 0KiB)#6: Compile Error (0ms, 0KiB)#7: Compile Error (0ms, 0KiB)#8: Compile Error (0ms, 0KiB)#9: Compile Error (0ms, 0KiB)向各位大神求解!!!
查看完整描述

2 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

itoa不是标准函数,请使用sscanf转换数字到字符串。
itoa 为c语言的一个函数。itoa 函数是一个广泛应用的,从非标准扩展到标准的C语言。它不能被移植,因为它不是标准定义下的C语言,但是,编译器通常在一个不遵循程式标准的模式下允许其通过header ,因为它是一个从逻辑对应到标准库的函数。itoa 取整数输入值,并将其转换为相应进制数字的字符串。

查看完整回答
反对 回复 2023-03-08
?
慕标琳琳

TA贡献1830条经验 获得超9个赞

找不到定义,这个编译器的标准库没有包含itoa的定义。

查看完整回答
反对 回复 2023-03-08
  • 2 回答
  • 0 关注
  • 170 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号