不使用标准库(stdio.h)将int转换为字符串 [英] convert int to string without using standard library (stdio.h)

查看:94
本文介绍了不使用标准库(stdio.h)将int转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是C的新手。你能不能帮我解决这个问题 -


我需要转换整数(和/或短)不使用sprintf字符串

(我没有标准的libray stdio.h)。


例如: -

int i = 2;

char ch''A''


我的结果应该是一个字符串==" A2"


结果不是标准输出 - 我有一个函数来从内存中读取/显示字符串。


谢谢,

cQ

Hi

I am a novice in C. Could you guys help me solve this problem -

I need to convert integer(and /short) to string without using sprintf
(I dont have standard libray stdio.h).

for instance:-
int i =2;
char ch ''A''

My result should be a string =="A2"

Results are not going to a standard output - I have a function to
readout/display string from memory.

Thanks,
cQ

推荐答案



ceeques写道:

ceeques wrote:




我是C的新手。你能不能帮我解决这个问题 -


我需要将整数(和/ short)转换为字符串而不使用sprintf

(我没有标准的libray stdio.h)。


for实例: -

int i = 2;

char ch''A


我的结果应该是一个字符串==" A2"
Hi

I am a novice in C. Could you guys help me solve this problem -

I need to convert integer(and /short) to string without using sprintf
(I dont have standard libray stdio.h).

for instance:-
int i =2;
char ch ''A

My result should be a string =="A2"



我不明白你想做什么。请

提供更多示例。还记下你的

函数应该接受什么作为参数以及它应该是什么样的
返回类型。并且还尽量避免语法

错误,如char ch''A'';这让你很难看到你的目标是什么。

I don''t understand what you''re trying to do. Please
provide more examples. Also write down what your
function should accept as arguments and what its
return type should be. And also try to avoid syntax
errors like char ch ''A'' ; it makes it harder to see what
your aim is.


结果不是标准输出 - 我有一个功能

读出/显示内存中的字符串。
Results are not going to a standard output - I have a function to
readout/display string from memory.



好​​的,那么结果应该去哪里?

Ok , so where results should go then ?


ceeques写道:
ceeques wrote:




我是C的新手。
Hi

I am a novice in C.



你有很多东西需要学习,而不仅仅是关于C. ;-)


一开始...

http://groups.google.com /group/comp....=int+to+string

-

彼得

You have much to learn, and not just about C. ;-)

Start with...

http://groups.google.com/group/comp....=int+to+string

--
Peter


感谢您的回复:


我需要将数字(int,short)转换为字符串但不能使用

sprintf因为我正在使用嵌入式系统。我想在系统输出的显示函数中混合文本和

数字(它不支持

printf)但它确实有一个文本屏幕功能接受

字符串。我希望显示带有消息的计数器。

希望我的问题现在很清楚。


提前谢谢,

cQ
sp****@gmail.com 写道:
Thanks for the repy:

I need to convert number (int, short) to a string but cannot use
sprintf as I am using an embedded system. I want to mix text and
number in a display function on the system''s output (It doesn''t support
printf) but it does have a text to screen function that accepts
strings. I would like to display counters with a message along with it.
Hope my question is clear now.

Thanks in advance,
cQ
sp****@gmail.com wrote:

ceeques写道:
ceeques wrote:




我是C的新手。你能帮助我吗?解决这个问题 -


我需要将整数(和/ short)转换为字符串而不使用sprintf

(我没有标准的libray stdio.h)。


例如: -

int i = 2;

char ch''A


我的结果应该是一个字符串==" A2"
Hi

I am a novice in C. Could you guys help me solve this problem -

I need to convert integer(and /short) to string without using sprintf
(I dont have standard libray stdio.h).

for instance:-
int i =2;
char ch ''A

My result should be a string =="A2"



我不明白你想做什么。请

提供更多示例。还记下你的

函数应该接受什么作为参数以及它应该是什么样的
返回类型。并且还尽量避免语法

错误,如char ch''A'';这让你很难看到你的目标是什么。


I don''t understand what you''re trying to do. Please
provide more examples. Also write down what your
function should accept as arguments and what its
return type should be. And also try to avoid syntax
errors like char ch ''A'' ; it makes it harder to see what
your aim is.


结果不是标准输出 - 我有一个功能

读出/显示内存中的字符串。
Results are not going to a standard output - I have a function to
readout/display string from memory.



好​​的,那么结果应该去哪里呢?


Ok , so where results should go then ?


这篇关于不使用标准库(stdio.h)将int转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆