如何在C中将Integer转换为String [英] How can I convert Integer to String in C

查看:139
本文介绍了如何在C中将Integer转换为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将整数(来自控制台let int i = 123的输入)转换为字符串(当我编写时表示("printf("%s,str);"​​)的意思是输出应该为"123".我会这样做吗?有人会给些提示吗?

I want to convert the integer (input from console let int i=123 ;)to string (means when I write ("printf ( "%s", str); ") The output should come "123". How do I do it ?Will anybody give some hints?

推荐答案

选中此选项:-

Check This One : -

int main(void)
{
  int num=86;
  char buf[50];

  snprintf(buf, 50, "%d", num);
  return 0;
}


使用
itoa()

中可用的方法

stdlib.h

>


这篇关于如何在C中将Integer转换为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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