Questions tagged [atoi]
atoi() is the C runtime library function for converting the ASCII representation of a number to an integer. This SO tag also applies to atol(), atoll(), and atoq() which perform the same conversion to types "long" and "long long".
atoi
437
questions
1
vote
2
answers
42
views
Problem to convert from ASCII to integers in Assembly AT&T 32 bit
ASM newbie here. I'm trying to convert in ASM AT&T (32-bit version) the following ASCII text from ASCII to integer (skipping the commas (44 in ASCII) and newlines (10 in ASCII)):
1,10,2,2\n2,7,6,7\...
2
votes
2
answers
137
views
ATOI in C messing with other strings in SERVER/CLIENT GMS application
We are trying to make a GMS server/client chat.
We are encountering an issue when using atoi on this part of the code
unserialize_tcp(buffer,&type, &grpname, &member_name, &...
-1
votes
1
answer
78
views
Memory modification when using strtol() and atoi() functions
I have the code (simplified a little for example)
char *op = CURRENT_PARSED_STRING.operand;
if(op){
printf("%s\n", op);
char q[] = "12h";
int a = atoi(q);
printf(&...
-1
votes
1
answer
53
views
have logical error, it proceed to addOrder even if it greater than max
my code has logical error i think, if I enter a number greater than max, the error void will show up, but the it still proceed on addOrder. I want to loop it if the user input is invalid it will ...
1
vote
2
answers
164
views
atoi() function returning garbage to terminal STM32, C lang
I have some question about atoi() function. I'm trying to convert string data received from HAL_UART_Receive_IT function to integer and next to sent again to terminal. And what I have at the exit it ...
1
vote
0
answers
133
views
implement atoi function in java
I am trying to implement the Atoi function in java, but it is showing me the error as:
java.lang.NumberFormatException: For input string:
at line 67, java.base/java.lang.NumberFormatException....
1
vote
2
answers
194
views
recreation of atoi function max long long error
I'm having an issue in the output although I defined the macro for max long long to treat overflow but it still gives me a the wrong output
# define LLONG_MAX 9223372036854775807LL
as you can see ...
1
vote
0
answers
93
views
Writing custom atoi() function
I am trying to write a c code that mulplies two numbers and I wrote a custom atoi() function to convert char to int. I tried running the exe file with the following arguments ./exe 2 3 but it giving ...
-1
votes
2
answers
790
views
Converting a string to integer in C for arduino
I'm trying to use the ATOI library function in C for Arduino to convert a string to an unsigned int. Out of all number data types I have chosen unsigned int as the number range does not need to be ...
0
votes
2
answers
46
views
What is the difference between the 2 functions that the latter doesn't consider all the strings in the argument but the first does
I wrote a function meant to act like the <stdlib.h> function atoi:
int _atoi(char *s)
{
int i, neg = 1, n = 0;
for (i = 0; s[i] != '\0'; i++)
{
if ((s[i] >= '0') &&...
-1
votes
1
answer
151
views
Why does GDB show a segfault when using atoi(), not when running the code [closed]
I get a segfault related to the following line:
int testenum = atoi(argv[1]);
The following is the whole error:
/build/bin/wrapper' has changed; re-reading symbols.
Temporary breakpoint 5 at 0x13f5: ...
1
vote
2
answers
648
views
atoi() accepting strings mixed with number
For a task I need use if atoi(INPUT) == 0 to check that a users input is a valid integer and not 0. The problem is when I enter any string that starts with an integer, it is automatically accepted, ...
1
vote
1
answer
97
views
How to join two numbers of type char and make them int type
Essentially I have a line which ends in two numbers. I can read the numbers eg) '4' and '1'. I want to concatenate them into '41' and then read that as an int type of value 41. Converting a single ...
0
votes
1
answer
63
views
Converting a Char Array into an Int array using a Function
I have been tasked with converting a char* array into an int array using a function. I'm new to C so I do apologize if this is a simple fix or an easy solution that I have just failed to notice.
This ...
0
votes
1
answer
89
views
int with atoi() calculated value is always 0
I am creating a program that will calculate first degree equations. My issue is that, because an equation will include characters and operands, I need to store date on a string and then pass them to ...