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++.
Questions tagged [itoa]
91 questions
1
vote
2 answers
custom ITOA not working right?
I wanted to make a custom ITOA function to put large numbers into small strings, this is what I have coded :
main(){
printf("itoa(2000000000,36)= '%s'",itoa(2000000000,36));
printf("itoa(36,36)= '%s'",itoa(36,36));
printf("itoa(37,36)=…
user1182183
1
vote
3 answers
'itoa' : function does not take 1 arguments & 'c' : undeclared identifier
I've been trying for 2 days now to get this code to work. It's just been error after error.
Can anyone point out what i'm doing wrong?
#include "stdafx.h"
#include
#include
using namespace std;
int main()
{
int h = 0;
…
![](../../users/profiles/1552047.webp)
Leinad177
- 41
- 1
- 7
0
votes
4 answers
What is the best practice of using itoa()
When I use itoa() it needs a char* _DstBuff, what is the best practice here?
#include "stdafx.h"
#include
using namespace std;
int main()
{
int num = 100;
// I'm sure here is no memory leak, but it needs to know the length.
char…
![](../../users/profiles/688912.webp)
shengy
- 8,380
- 3
- 33
- 61
0
votes
3 answers
itoa creates an infinite loop in C++
This is very strange. itoa(); seems to create an infinite loop.
for(int i = 0; i < 10; i++)
{
char buffer[1];
itoa(i, buffer, 10);
std::cout << buffer;
}
Why on earth does it do that? I've tried using different variables…
![](../../users/profiles/998204.webp)
Griffin
- 646
- 6
- 18
0
votes
2 answers
itoa in a template function
Code goes first:
template
void do_sth(int count)
{
char str_count[10];
//...
itoa(count, str_count, 10);
//...
}
but I got some compile-error like this:
error: there are no arguments to ‘itoa’ that depend on a template…
![](../../users/profiles/888051.webp)
Alcott
- 15,679
- 24
- 106
- 170
0
votes
2 answers
Integer number as char* for dummies
Question has been asking before, but I am still a bit at a loss as to the best way. I have an integer and would like to obtain a char* to use as a member of a struct.
Similar questions are for example
here or here.
I'd rather not use stringstream…
![](../../users/profiles/698504.webp)
Cookie
- 10,754
- 13
- 47
- 69
0
votes
1 answer
inteager to argument in C; gdb shows no errors, function is not giving output
**
Hello :)
So I have this task to write a program that will convert int to arg using malloc and well it all works fine, gdb shows no errors, but it is not printing any output in this form. If i delete itoa_buffer[i] = '\0'; than sometimes it shows…
![](../../users/profiles/15171600.webp)
Tony
- 25
- 5
0
votes
1 answer
Segfault when trying to recode itoa in C
Newbie trying to recode itoa here.
I am not quite sure about how the itoa function works, but here's how I want mine to work for now :
char *ft_itoa(int nb, char *str)
I want each digit of nb to be converted into a char which is to be put in…
![](../../users/profiles/4438612.webp)
badakzz
- 21
- 5
0
votes
1 answer
why 1 is getting added at the end of string? in this code
I want to create a text file with the name entered by the user and with id concatinated,The file is getting created but the 1 is getting added at the last of extension every time i run it
#include "stdio.h"
#include "string.h"
#include…
![](../../users/profiles/12382510.webp)
gurukiranx
- 93
- 8
0
votes
1 answer
How to print signed integer in x86 assembly (NASM) on Mac
I found an implementation of unsigned integer conversion in x86 assembly, and I tried plugging it in but being new to assembly and not having a debugging env there yet, it's difficult to understand why it's not working. I would also like it to work…
![](../../users/profiles/169992.webp)
Lance Pollard
- 66,757
- 77
- 237
- 416
0
votes
5 answers
Problem with concatenation + itoa
I have the following code:
char stringHour[50], stringMinute[50], stringSecond[50];
// lots of code...
itoa(hour, stringHour, 10);
itoa(minute, stringMinute, 10);
itoa(second, stringSecond, 10);
strcat(":", stringSecond);
strcat(":",…
![](../../users/profiles/280698.webp)
F. P.
- 4,708
- 8
- 49
- 78
0
votes
1 answer
Arduino: itoa prints 201 and sprintf prints the intended 99
I have difficulties printing a byte value (uint8_t) with itoa(), needed to print a percentage of volume. I want to use this function because it reduce binary size.
Two versions of an updateStats function (prints stats on a oled display using…
![](../../users/profiles/565244.webp)
Codebeat
- 6,123
- 5
- 51
- 88
0
votes
1 answer
itoa function for byte array
Is there an easy way to do the following:
Convert a byte array like so {1,3,0,2,4} to a char array like so {'1','3','0','2','4'} or "13024".
I can do the following ( I think ) but it is more cumbersome:
…
user3493202
0
votes
3 answers
itoa providing 7-bit output to character input
I am trying to convert a character to its binary using inbuilt library (itoa) in C(gcc v-5.1) using example from Conversion of Char to Binary in C , but i'm getting a 7-bit output for a character input to itoa function.But since a character in C is…
![](../../users/profiles/6513362.webp)
harry
- 11
- 3
0
votes
3 answers
How do you properly implement turning an int into a string?
I am writing a bit of an operating system, and I require the ability to print the addition of a variable. I have a working atoi function and so I reversed it to give me an itoa function. There is no way to access free memory, so I need to figure out…
![](../../users/profiles/1620201.webp)
Blue Okiris
- 198
- 9