String sprintf(将int转换为char[])
在我的程序中,我尝试将int转换为char[20] 我尝试通过以下方式来实现这一点:String sprintf(将int转换为char[]),string,int,type-conversion,printf,String,Int,Type Conversion,Printf,在我的程序中,我尝试将int转换为char[20] 我尝试通过以下方式来实现这一点: char str[20]; sprintf(str, "%d", timer); 其中计时器是int 但是当我构建这段代码时,我得到了以下警告 Type implicit declaration of function 'sprintf' [-Wimplicit-function-declaration] incompatible implicit declaration of buil
char str[20];
sprintf(str, "%d", timer);
其中计时器是int
但是当我构建这段代码时,我得到了以下警告
Type implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
incompatible implicit declaration of built-in function 'sprintf' [enabled by default]
这是什么意思
注:(我已经包括string.h和stdlib.h)
太好了,我在代码中添加了stdio.h,现在警告消失了,结果给了我一个更大的错误
未定义的对“\u sbrk”的引用您可能需要将
sprintf(str,“%d”,timer)
放在函数内部(而不是源代码的全局部分)
stdio.h
比如:
#include <stdlib.h>
char str[20];
// SPOT #1
int f() {
sprintf(str, "%d", timer); // this won't work if placed on SPOT #1
}
#包括
char-str[20];
//点#1
int f(){
sprintf(str,“%d”,timer);//如果放在现场,这将不起作用#1
}
要使用sprintf()
您必须#包括
,您要确保还添加了对它的引用,它位于函数内部。。。所以这绝对不是事实是的,他是,我是最伟大的。我甚至不能接受他的飞机,他太快了
stdio.h