整数到字符 [英] integer to characters
问题描述
我想将3位整数更改为字符,我该怎么做?
3位整数可能是123,23或3
我想将整数更改为123, 23 QUOT;或 3
thx
I want to change a 3 digits integer to characters, how can i do that?
the 3 digits integer maybe 123, 23 or 3
I want to change the integer to "123", " 23" or " 3"
thx
推荐答案
Alan写道:
Alan wrote:
我想将3位整数更改为字符,我该怎么做?
3位整数也许123,23或3
我想将整数更改为123, 23 QUOT;或 3
I want to change a 3 digits integer to characters, how can i do that?
the 3 digits integer maybe 123, 23 or 3
I want to change the integer to "123", " 23" or " 3"
你不想改变任何东西。
你想把一个整数转换成它的文本表示。
char Buffer [20];
int Number = 123;
sprintf(Buffer,"%d",Number); <另外:当发布到alt.comp.lang.learn.c -c ++总是
表示你需要一种解决方案的语言。
我们讨论C和C ++。 C ++解决方案完全不同于
。
-
Karl Heinz Buchegger
kb ****** @ gascad.at
Alan写道:
Alan wrote:
我想将3位整数更改为字符,我该怎么做?
3位整数可能是123,23或3
我想要将整数更改为123, 23 QUOT;或 3
thx
I want to change a 3 digits integer to characters, how can i do that?
the 3 digits integer maybe 123, 23 or 3
I want to change the integer to "123", " 23" or " 3"
thx
char arr [4];
int val = 123;
arr [0] =''0''+ val / 100;
arr [1] =''0''+(val%100)/ 10;
arr [2] =''0''+ val%10;
arr [3] =''\ 0'';
printf("%s",arr);
Rick
char arr[4];
int val = 123;
arr[0] = ''0'' + val/100;
arr[1] = ''0'' + (val%100)/10;
arr[2] = ''0'' + val%10;
arr[3] = ''\0'';
printf("%s", arr);
Rick
" Karl Heinz Buchegger" < KB ****** @ gascad.at> ????
新闻:3F *************** @ gascad.at ??? ...
"Karl Heinz Buchegger" <kb******@gascad.at> ???
news:3F***************@gascad.at ???...
Alan写道:
Alan wrote:
我想将3位整数更改为字符,我该怎么做?
3位整数可能是123,23或者3
我想将整数更改为123, 23 QUOT;或 3
你不想改变任何东西。
你想把一个整数转换成它的文本表示。
char Buffer [20];
int Number = 123;
sprintf(Buffer,"%d",Number);
I want to change a 3 digits integer to characters, how can i do that?
the 3 digits integer maybe 123, 23 or 3
I want to change the integer to "123", " 23" or " 3"
You don''t want to change anything.
You want to convert an integer into its textual representation.
char Buffer[20];
int Number = 123;
sprintf( Buffer, "%d", Number );
是否有与sprintf()相同的函数但写入文件?
因为我找不到一个名为fsprintf()的函数
thx
另外:发布到alt.comp.lang.learn.c-c ++时,总是
表明您需要解决方案的语言。那里我们讨论C和C ++。 C ++解决方案完全不同。
Is there any function same as sprintf() but write to file?
because I can''t find a function called "fsprintf()"
thx
Also: When posting to alt.comp.lang.learn.c-c++ always
indicate which language you need a solution for. There
we discuss C and C++. The C++ solution would be completely
different.
对不起,下次我会这样做
sorry, next time I will do so
这篇关于整数到字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!