C Error Undefined Reference To Itoa
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Undefined Reference To Itoa Gcc
policies of this site About Us Learn more about Stack Overflow the undefined reference to itoa linux company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users clang itoa Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes
Itoa C
a minute: Sign up gcc error : undefined reference to `itoa' up vote 1 down vote favorite if I include stdlib.h then also itoa() is not recognized. My code : %{ #include "stdlib.h" #include
Itoa Linux
S %type
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and itoa implementation policies of this site About Us Learn more about Stack Overflow the
Itoa Was Not Declared In This Scope
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users _itoa_s Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes http://stackoverflow.com/questions/12970439/gcc-error-undefined-reference-to-itoa a minute: Sign up Where is the itoa function in Linux? up vote 82 down vote favorite 18 itoa() is a really handy function to convert a number to a string. Linux does not seem to have itoa(), is there an equivalent function or do I have to use sprintf(str, "%d", num)? c linux share|improve this question edited Jun 3 '14 at http://stackoverflow.com/questions/190229/where-is-the-itoa-function-in-linux 14:42 David Guyon 1,1291129 asked Oct 10 '08 at 5:29 Adam Pierce 17.6k175680 2 any reason not to use sprintf(str, "%d", num)? is it much slower than itoa? –javapowered Sep 15 '14 at 18:53 @javapowered, for one, itoa allows arbitrary base conversion, printf specifiers don't. –vladr Aug 26 at 15:35 add a comment| 14 Answers 14 active oldest votes up vote 57 down vote accepted EDIT: Sorry, I should have remembered that this machine is decidedly non-standard, having plugged in various non-standard libc implementations for academic purposes ;-) As itoa() is indeed non-standard, as mentioned by several helpful commenters, it is best to use sprintf(target_string,"%d",source_int) or (better yet, because it's safe from buffer overflows) snprintf(target_string, size_of_target_string_in_bytes, "%d", source_int). I know it's not quite as concise or cool as itoa(), but at least you can Write Once, Run Everywhere (tm) ;-) Here's the old (edited) answer You are correct in stating that the default gcc libc does not include itoa(), like several other platforms, due to it not technically being a part of the standard. See here for a little
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow http://askubuntu.com/questions/196867/error-linking-standard-header-file-in-gcc the company Business Learn more about hiring developers or posting ads with us Ask Ubuntu http://mailman.linuxchix.org/pipermail/programming/2005-December/002001.html Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Error linking standard header file in gcc undefined reference up vote 0 down vote favorite 1 I've a simple code - this works on other platforms but does not work in ubuntu. #include
[ thread ] [ subject ] [ author ] On Sat, Dec 17, 2005 at 02:36:12PM +0200, Asl? wrote: > hi everyone, > i have quite an incomprehensible problem. I am writing some kind of an > authentication application between servers and clients using socket APIs. > This is the part of my code that drove me crazy: > > char error_message[MAX_ERROR] ="Name not registered"; > > itoa(strlen(error_message),error_len,10); > > i compiled the file with gcc (gcc file_s.c -o file_s) and got the message: > > In function `main': > : undefined reference to `itoa' > collect2: ld returned 1 exit status > > which seems to be a linker error. I was quite sure that "itoa" is in stdlib, > and i include stdlib in my code. Unfortunately, this (very handy) function is not ANSI C, even though it's often found on other platforms/compilers, e.g. Microsoft. IOW, it's simply not available in stdlib on Linux. If you only need decimal (or hex) number base, I'd suggest to use sprintf() instead -- that's at least highly portable. Also see here http://www.jb.man.ac.uk/~slowe/cpp/itoa.html for a related discussion. Cheers, Almut Previous message: [prog] undefined reference to itoa Next message: [prog] undefined reference to itoa Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] More information about the Programming mailing list