Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 05-27-2004, 04:28 AM   #1
LQ Newbie
Registered: Mar 2004
Distribution: Slackware 9.1
Posts: 7

Rep: Reputation: 0
Integer To a String in C

h is an int; number in the 5000's.

char *ret;

got a for loop running

this is where h is being set. i need to add -h to the end of ret.
so ret will look something like this when the loop is done
5000-5001-5002 but a string.
Old 05-27-2004, 04:45 AM   #2
Registered: Jul 2003
Posts: 34

Rep: Reputation: 15
You're looking for itoa();
This is a good little tutorial on itoa() and some others you might be interested in:
Hope this helps.
Old 05-27-2004, 05:46 AM   #3
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 34
sprintf() will also do what you need.
void foo(char *ret){
        int h=0;
        char tmp[6]={0x00};


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
C++ string to integer conversion fatman Programming 6 06-18-2006 09:17 AM
C how to convert an integer to string? totti10 Programming 10 11-10-2005 06:49 AM
How do you convert a string to an integer? wbdune Linux - Newbie 11 11-01-2003 03:01 PM
C programming assigning an integer value to a string Linh Programming 4 06-22-2003 08:02 AM
convert integer to string (atoi?) lea Programming 6 10-11-2002 06:16 PM

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

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