Sponsored Content
Full Discussion: atoi
Top Forums Programming atoi Post 101531 by bankpro on Thursday 9th of March 2006 10:08:54 AM
Old 03-09-2006
atoi

i know what is the use of atoi function....
converts string to int.

but whenever i use that it gives me 0....
could any one help in this issue..

eg.
int i;
char str[20];
str="name";
i=atoi(str);
i gives me 0. why?
 

2 More Discussions You Might Find Interesting

1. Programming

help with atoi and macros in C

I have a PORT_NUM macro (10 digits long number) in a server file, if i do htons(PORT_NUM) i get warning: this decimal constant is unsigned only in ISO C90 warning: large integer implicitly truncated to unsigned type whats wrong with this? (2 Replies)
Discussion started by: omega666
2 Replies

2. Programming

type conversion C, atoi()

In the book "The C programming language"; second edition, chapter 2.7 there is a snippet which is supposed to: "convert a string of digits into its numeric equivalent". int atoi(char s) { int i, n; n = 0; for ( i = 0; s >= '0' && s <= '9'; ++i) n = 10 * n + (s -... (4 Replies)
Discussion started by: tornow
4 Replies
ATOI(3) 						     Linux Programmer's Manual							   ATOI(3)

NAME
atoi, atol, atoll, atoq - convert a string to an integer. SYNOPSIS
#include <stdlib.h> int atoi(const char *nptr); long atol(const char *nptr); long long atoll(const char *nptr); long long atoq(const char *nptr); DESCRIPTION
The atoi() function converts the initial portion of the string pointed to by nptr to int. The behaviour is the same as strtol(nptr, (char **)NULL, 10); except that atoi() does not detect errors. The atol() and atoll() functions behave the same as atoi(), except that they convert the initial portion of the string to their return type of long or long long. atoq() is an obsolete name for atoll(). RETURN VALUE
The converted value. CONFORMING TO
SVID 3, POSIX.1, BSD 4.3, ISO/IEC 9899. ISO/IEC 9899:1990 (C89) and POSIX.1 (1996 edition) include the functions atoi() and atol() only; C99 adds the function atoll(). NOTES
The non-standard atoq() function is not present in libc 4.6.27 or glibc 2, but is present in libc5 and libc 4.7 (though only as an inline function in <stdlib.h> until libc 5.4.44). The atoll() function is present in glibc 2 since version 2.0.2, but not in libc4 or libc5. SEE ALSO
atof(3), strtod(3), strtol(3), strtoul(3) GNU
2000-12-17 ATOI(3)
All times are GMT -4. The time now is 03:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy