ASCII转换为数字ASCII字符用C [英] Convert ASCII number to ASCII Character in C

查看:476
本文介绍了ASCII转换为数字ASCII字符用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C是有没有办法转换类型为int到相应的ASCII字符作为一个字符的ASCII值?

In C is there a way to convert an ASCII value typed as an int into the the corresponding ASCII character as a char?

推荐答案

如果 I INT ,然后

char c = i;

使得它字符。你可能想增加一个检查该值< 128 如果它来自不受信任的来源。文件ctype.h> ,如果您的系统上(见@Steve杰索普的这最好用 isascii &LT完成这个答案的评论)。

makes it a char. You might want to add a check that the value is <128 if it comes from an untrusted source. This is best done with isascii from <ctype.h>, if available on your system (see @Steve Jessop's comment to this answer).

这篇关于ASCII转换为数字ASCII字符用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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