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
ATOL(3) 						   BSD Library Functions Manual 						   ATOL(3)

NAME
atol, atoll, atol_l, atoll_l -- convert ASCII string to long or long long integer LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> long atol(const char *str); long long atoll(const char *str); #include <xlocale.h> long atol_l(const char *str, locale_t loc); long long atoll_l(const char *str, locale_t loc); DESCRIPTION
The atol() function converts the initial portion of the string pointed to by str to long integer representation. It is equivalent to: strtol(str, (char **)NULL, 10); The atoll() function converts the initial portion of the string pointed to by str to long long integer representation. It is equivalent to: strtoll(str, (char **)NULL, 10); While the atol() and atoll() functions use the current locale, the atol_l() and atoll_l() functions may be passed locales directly. See xlocale(3) for more information. ERRORS
The functions atol() and atoll() need not affect the value of errno on an error. SEE ALSO
atof(3), atoi(3), strtod(3), strtol(3), strtoul(3), xlocale(3) STANDARDS
The atol() function conforms to ISO/IEC 9899:1990 (``ISO C90''). The atoll() function conforms to ISO/IEC 9899:1999 (``ISO C99''). BSD
November 28, 2001 BSD
All times are GMT -4. The time now is 10:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy