- 1

What is the use of atoi function in c

I don't understand the concept please give me an explanation with example

20th Jul 2019, 4:34 PM
Gayathri Manalan
Gayathri Manalan - avatar
11 Respostas
+ 7
char number atoi
22nd Jul 2021, 10:09 AM
Yashika Patel
+ 5
~ swim ~ it returns 0 i think if the string is not digit
20th Jul 2019, 5:12 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 4
Converts an string to integer.
21st Jul 2019, 7:14 AM
Manoj
Manoj - avatar
+ 3
Gayathri Manalan - or + are valid chars for atoi. atoi("-56") retuns -56 ✳AsterisK✳ undefined behaviour if the number is out of range. But if not a number it returns zero as ~ swim ~ said... atoi("555555555555555") --> undefinded atoi(" -56") --> -56 atoi("fghi") --> 0 :)
21st Jul 2019, 6:00 AM
unChabon
unChabon - avatar
+ 1
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { int val; char str[20]; strcpy(str, "98993489"); val = atoi(str); printf("String value = %s, Int value = %d\n", str, val); strcpy(str, "hello"); val = atoi(str); printf("String value = %s, Int value = %d\n", str, val); return(0); } Run this code using numbers and alphabetic. You will understand better.
21st Jul 2019, 3:27 PM
MADHU KUMAR KOULAS
MADHU KUMAR KOULAS - avatar
+ 1
In simple words "654" value is not equal to 654. So it converts "654" to 654 value...😉😉😉😉
21st Jul 2019, 3:30 PM
MADHU KUMAR KOULAS
MADHU KUMAR KOULAS - avatar
+ 1
It stands for ASCII to Integer.
22nd Jul 2019, 1:42 AM
Sonic
Sonic - avatar
+ 1
the atoi() converts a string to an integer and atoi() skips all white-space characters at the beginning of the string.
13th Sep 2020, 5:42 AM
Sakina Hassany
Sakina Hassany - avatar
0
char number atoi
22nd Jul 2023, 3:47 AM
NAVEENKUMAR R
NAVEENKUMAR R - avatar