LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-27-2008, 06:58 AM   #1
hai12345
LQ Newbie
 
Registered: Jun 2008
Posts: 9

Rep: Reputation: 0
itoa


hi,

any function is there in linux inceded of itoa.but it is working in windows.
 
Old 06-28-2008, 02:26 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
sprintf() ?
--- rod.
 
Old 06-28-2008, 04:30 AM   #3
Swagata Paul
Member
 
Registered: Jun 2008
Location: Kolkata, India
Posts: 57

Rep: Reputation: 15
yes,
u can use sprintf .......

exapmle,

main()
{

....
char ar[20];
int x=255;

sprintf(ar,"%d",x);


....

}
 
Old 06-30-2008, 12:25 AM   #4
hai12345
LQ Newbie
 
Registered: Jun 2008
Posts: 9

Original Poster
Rep: Reputation: 0
hi thns,

i want to convert integer to string.sprintf is not working correctly.




pls help me.
 
Old 06-30-2008, 01:01 AM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

"Itoa" was popular in a number of DOS-era compilers (like Turbo C), but it was never officially a "Standard C" library function, and it was notoriously vulnerable to buffer overruns.

"sprintf()" is an alternative to "itoa()"; "snprintf()" is an even better alternative:
Code:
#include <stdio.h>

int
main ()
{
  char s[80];
  int iret = snprintf (s, sizeof (s), "%d", 100);
  printf ("string= %s, snprintf return value= %d...\n", s, iret);
  return 0;
}
'Hope that helps .. PSM

PS:
I assume when you say "itoa isn't working correctly", you probably mean that your compiler isn't recognizing it as a valid function. Again, "snprintf" is probably both a more portable and more robust solution...
 
Old 06-30-2008, 01:08 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by hai12345 View Post
hi thns,

i want to convert integer to string.sprintf is not working correctly.




pls help me.
Please help us to help you. 'not working correctly' is not enough information to diagnose your problem. Show us what you have tried, and explain in what way it is failing.

--- rod.
 
  


Reply



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
GCC isn't detecting exit() and itoa()! Kixdemp Programming 3 03-12-2006 09:34 PM
Can't find itoa() russoue Programming 2 12-07-2004 12:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:17 AM.

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
Open Source Consulting | Domain Registration