如何将整数转换为ASCII字符?
将整数值转换为ASCII最简单的方法
字符格式是什么?
我尝试使用sprintf()。它有效。
还有其他办法吗?
目标::
我想转换一个整数值3,写入字符串缓冲区。
我做了什么:
.....
.... 。
char myStr [];
int myInt = 3;
sprintf(myStr,%d,myInt);
.....
.....
请评论。
What is the most easiest way to convert an integer value to ASCII
character format ?
I tried with sprintf(). It works.
Is there any other way to do that ?
Objective::
I like to convert an integer value of 3 and write into a string buffer.
What I did:
.....
.....
char myStr[];
int myInt = 3;
sprintf(myStr, %d,myInt);
.....
.....
Please comment.
ak ********** **** @gmail.com 写道:
将整数值转换为ASCII
字符格式最简单的方法是什么?
我试过用sprintf ()。它有效。
有没有其他方法可以做到这一点?
目标::
我喜欢转换整数值3并写入字符串缓冲区。
我做了什么:
....
....
char myStr [];
int myInt = 3;
sprintf(myStr ,%d,myInt);
....
....
请评论。
What is the most easiest way to convert an integer value to ASCII
character format ?
I tried with sprintf(). It works.
Is there any other way to do that ?
Objective::
I like to convert an integer value of 3 and write into a string buffer.
What I did:
....
....
char myStr[];
int myInt = 3;
sprintf(myStr, %d,myInt);
....
....
Please comment.
#define DIGILEN log10(MAX_INT)+2
char buf [DIGILEN];
sprintf(buf,"%d",int_var);
Xavier
#define DIGILEN log10 (MAX_INT) +2
char buf[DIGILEN];
sprintf(buf, "%d", int_var);
Xavier
serrand写道:
serrand wrote:
ak ************** @ gmail.com 写道:
ak**************@gmail.com wrote:
将整数值转换为ASCII
字符格式最简单的方法是什么?
我尝试使用sprintf()。它有效。
有没有其他方法可以做到这一点?
目标::
我喜欢转换整数值3并写入字符串缓冲区。
我做了什么:
....
....
char myStr [];
int myInt = 3;
sprintf(myStr ,%d,myInt);
....
....
请评论。
What is the most easiest way to convert an integer value to ASCII
character format ?
I tried with sprintf(). It works.
Is there any other way to do that ?
Objective::
I like to convert an integer value of 3 and write into a string buffer.
What I did:
....
....
char myStr[];
int myInt = 3;
sprintf(myStr, %d,myInt);
....
....
Please comment.
#define DIGILEN log10 (MAX_INT)+2
char buf [DIGILEN];
sprintf(buf,"%d",int_var);
Xavier
#define DIGILEN log10 (MAX_INT) +2
char buf[DIGILEN];
sprintf(buf, "%d", int_var);
Xavier
oops ...抱歉
#define DIGILEN(int)(log10(MAX_INT)+3)
你的方式似乎是最简单的...
sprintf正在做与printf相同的工作:在stdin的wheras printf输出
sprintf输出在它的第一个参数中,它必须是一个分配的字符串
Xavier
oops... sorry
#define DIGILEN (int)(log10 (MAX_INT) +3)
Your way seems to be the simpliest...
sprintf is doing the same job as printf : wheras printf outputs in stdin
sprintf outputs in its first argument, which have to be an allocated string
Xavier
也许itoa可以使用。但它不是标准功能。
Maybe itoa could be used. But it''s not a standard function.