Questions tagged [itoa]

Questions about itoa function may have this tag. Despite being supported by some compilers, this function is not defined in ANSI-C and it is not part of C++.

91 questions
151
votes
18 answers

Alternative to itoa() for converting integer to string C++?

I was wondering if there was an alternative to itoa() for converting an integer to a string because when I run it in visual Studio I get warnings, and when I try to build my program under Linux, I get a compilation error.
Tomek
  • 4,527
  • 14
  • 40
  • 48
25
votes
3 answers

converting number to string in lisp

I tried to find a lisp function to convert between numbers and strings and after a little googling I fond a function with the same name. when I entered (itoa 1) SLIME printed: Undefined function ITOA called with arguments (1) . How can I do the…
elyashiv
  • 3,503
  • 2
  • 26
  • 48
19
votes
1 answer

What does "itoa" stand for in strconv.Itoa?

This might sound like a silly question... But I can't find anywhere what the "a" in strconv.Itoa actually stands for. If its taking an integer and turning it into a string, why isn't the function called Itos?
Eric R.
  • 883
  • 1
  • 9
  • 18
12
votes
12 answers

Convert integer to string without access to libraries

I recently read a sample job interview question: Write a function to convert an integer to a string. Assume you do not have access to library functions i.e., itoa(), etc... How would you go about this?
Nick Sinas
  • 2,544
  • 10
  • 40
  • 51
12
votes
6 answers

itoa function problem

I'm working on Eclipse inside Ubuntu environment on my C++ project. I use the itoa function (which works perfectly on Visual Studio) and the compiler complains that itoa is undeclared. I included , , which doesn't help.
Aviadjo
  • 605
  • 5
  • 17
  • 34
11
votes
7 answers

itoa() c implementation int min underflow

I'm running some test cases against my itoa() function but keep getting did not allocate memory for the int min value I'm doing the check but it's something I'm missing here, what is it? char *ft_itoa(int x) { char *s; size_t len; long…
franklinexpress
  • 1,079
  • 12
  • 42
11
votes
3 answers

How to generate a constexpr version string from three integers (or perhaps a git/SVN commit/rev. string)?

Say I have constexpr const std::uint8_t major = 1; constexpr const std::uint8_t minor = 10; constexpr const std::uint8_t bugfix = 0; and I want constexpr const char* version_string(){ ... } to return the equivalent of "1.10.0" in this example, how…
rubenvb
  • 69,525
  • 30
  • 173
  • 306
11
votes
3 answers

atoi is a standard function. But itoa is not. Why?

Why this distinction? I've landed up with terrible problems, assuming itoa to be in stdlib.h and finally ending up with linking a custom version of itoa with a different prototype and thus producing some crazy errors. So, why isn't itoa not a…
Pavan Manjunath
  • 24,688
  • 11
  • 92
  • 120
10
votes
5 answers

What is the difference between _itoa and itoa?

Visual Studio is yelling at me about using itoa() saying to use _itoa() instead? It looks to me like they are the same function. What gives?
Polaris878
  • 33,681
  • 35
  • 107
  • 140
10
votes
2 answers

gcc error : undefined reference to `itoa'

if I include stdlib.h then also itoa() is not recognized. My code : %{ #include "stdlib.h" #include #include int yylex(void); char p[10]="t",n1[10]; int n ='0'; %} %union { char *dval; } %token ID %left '+' '-' %left '*'…
Anubha
  • 1,195
  • 6
  • 21
  • 34
9
votes
2 answers

C Error: undefined reference to '_itoa'

I'm trying to convert an integer to a character to write to a file, using this line: fputc(itoa(size, tempBuffer, 10), saveFile); and I receive this warning and message: warning: implicit declaration of 'itoa' undefined reference to '_itoa' I've…
aytee17
  • 425
  • 2
  • 5
  • 9
7
votes
3 answers

'itoa': The POSIX name for this item is deprecated

I'm trying to convert an int into a string by doing this: int id = 12689; char snum[MAX]; itoa(id, snum, 10); I get the following error: 'itoa': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _itoa.
Dan Murphy
  • 185
  • 1
  • 2
  • 12
7
votes
2 answers

Proper way to convert (many!) numbers to strings without allocations in Qt

tl;dr I want to call QString::number(int) many times per second. It is very slow: seems like it allocates a new string each time. Tried to use setNum on same string instead, still no joy. Original, long question: The problem I have a big array of…
NIA
  • 2,433
  • 19
  • 31
7
votes
5 answers

Create char array of integer using digits as size

I am trying to create a char array in C, to fill it with the digits of an int, but the int can be of any number of digits. I'm using a created function called getDigits(int num), that returns a number of digits the int has. char…
anairinac
  • 549
  • 3
  • 6
  • 18
6
votes
2 answers

How to convert an integer to a string portably?

I was looking for a way to convert an integer to a string in a portable manner (portable among at least Windows & Linux and x86 and x86_64) and I though itoa(X) to be standard just like atoi(1). But I read the following in the Wikipedia entry: The…
1
2 3 4 5 6 7