转换INT,双成char数组中的C或目标C [英] Converting int, double to char array in C or Objective C

查看:112
本文介绍了转换INT,双成char数组中的C或目标C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要转换的int char数组和双到字符数组。任何方式在C或目标C这样做的。

I want to convert int to char array and double to char array. Any way of doing this in C or Objective C.

推荐答案

如果你想治疗的人数为字符的数组,你可以把地址和投指针:

If you want to treat the number as an array of char, you can take the address and cast the pointer:

int i;
double d;
char * ic = (char *) &i;
char * dc = (char *) &d;

然后 IC DC 是指向字符 。他们不是零结尾的,所以你不能把它们作为字符串,但它们可以被用来作为数组。

then ic and dc are pointers to char. They aren't zero-terminated, so you can't use them as strings, but they can be used as arrays.

这篇关于转换INT,双成char数组中的C或目标C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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