LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 10-14-2005, 07:51 AM   #1
gjagadish
Member
 
Registered: Oct 2005
Location: India
Distribution: Fedora Core
Posts: 88

Rep: Reputation: 15
Question Convert Integer to Char


Hi all,

Cany anyone tell me, How to convert integer to char. i.e equivalent to itoa.

I can't find any equivalent itoa function in linux libraries. And is there any

equivalent C++ String Object in Linux.

thanx in advance

Jagadish
 
Old 10-14-2005, 08:02 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
In C strtol and strtoul (resp. string to long and string to unsigned long). There must be similar C++ functions, but I'm not an C++ programmer. Something like string.strtol?
 
Old 10-14-2005, 08:11 AM   #3
gjagadish
Member
 
Registered: Oct 2005
Location: India
Distribution: Fedora Core
Posts: 88

Original Poster
Rep: Reputation: 15
Hi,

thanx for ur reply. But it doesn't help me.
becoz, i asked for integer to char and not string to long int.

plsss help me.

thanx
Jagadish
 
Old 10-14-2005, 09:28 AM   #4
sind
Member
 
Registered: Jun 2005
Posts: 75

Rep: Reputation: 15
This would be one way of doing it:

Code:
#define BUF_SIZE 16

char buf[BUF_SIZE];
int value = 500;

snprintf(buf, BUF_SIZE, "%d", value);

/* buf now contains the string "500" */
~sind
 
Old 10-14-2005, 09:45 AM   #5
gjagadish
Member
 
Registered: Oct 2005
Location: India
Distribution: Fedora Core
Posts: 88

Original Poster
Rep: Reputation: 15
Hi Sind,

thank u very much. u gave what i need.

Jagadish
 
Old 10-14-2005, 11:09 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally posted by gjagadish
Hi,

thanx for ur reply. But it doesn't help me.
becoz, i asked for integer to char and not string to long int.

plsss help me.

thanx
Jagadish
Sorry, confused
 
  


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
C how to convert an integer to string? totti10 Programming 10 11-10-2005 06:49 AM
C Problem---convert char to char* totti10 Programming 11 11-06-2004 12:32 PM
how to convert charcter to integer husniteja Programming 6 08-30-2004 10:29 AM
convert from char* to unsigned char* D J Linux - Software 2 02-20-2004 05:09 AM
How do you convert a string to an integer? wbdune Linux - Newbie 11 11-01-2003 03:01 PM

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

All times are GMT -5. The time now is 07:54 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