469,125 Members | 1,640 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

A query

I need a linux C program to convert an integer to ASCII character ?
Feb 25 '08 #1
1 1492
849 Expert 512MB
Characters and integers are directly comparable and castable to each other. Thus, assuming your int is 0<=x<=127, you can simply cast like so:

Expand|Select|Wrap|Line Numbers
  1. int x;
  2. char c = (char) x;
If you want the character representation of a number (like "123" for 123), try looking into sprintf, since itoa isn't standard for some silly reason.
Feb 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.