LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-14-2002, 09:02 AM   #1
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Rep: Reputation: 31
convert integers to ascii


hello

does somebody know if there is a built-in function in c to convert an integer vaue into a "string"?

i need to store for example 234 in this form:

char *value;

the result then shoud be:
*(value+0)=2
*(value+1)=3
*(value+2)=4

any ideas? or do i have to write my own function to do this???

thanks

raven
 
Old 02-14-2002, 11:29 AM   #2
Tonneman
LQ Newbie
 
Registered: Dec 2001
Posts: 14

Rep: Reputation: 0
You need your output string to be already allocated, then do something like:

int Number = 234;

char Value[MAX_SIZE];

sprintf(Value, "%d", Number);
 
Old 02-15-2002, 02:47 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
The function itoa is also made specifically for converting integers to a character array.
 
Old 02-15-2002, 03:32 AM   #4
Tonneman
LQ Newbie
 
Registered: Dec 2001
Posts: 14

Rep: Reputation: 0
Quote:
Originally posted by Mik
The function itoa is also made specifically for converting integers to a character array.
Ach! I knew there was one that did that. But I couldn't remember what it was, and I could only find atoi.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert ASCII text to an audio file ed_homeLinux Linux - Software 1 07-22-2005 12:30 PM
function in shell to convert hexadecimal into ascii suchi_s Linux - Software 1 04-01-2005 02:07 PM
64-bit integers in C nodger Programming 1 03-31-2005 08:06 AM
in linux & c/c++: how do I convert an ascii string to utf8 & vice versa? davidh_uk Programming 2 02-06-2005 05:55 PM
allegro + hex integers CamelofCamelot Programming 4 01-04-2004 09:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration