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".
What is the purpose to run
if n is 0 ?
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;
str="name";
i=atoi(str);
i gives me 0. why? (3 Replies)
Hello,everyone here.
I'm coding with KSH to achieve exploring the disk space and judging whether it closes to overflow.But It seems that no one way to convert a string variable to integer.
df | read A B C D E F G H I J K L
print ${L}
Can I convert L to integer type?
Thanks for... (2 Replies)
Dear colleagues,
One of my friend have a problem with c code. While compiling a c program it displays a message like
"array type has incomplete element type". Any body can provide a solution for it.
Jaganadh.G (1 Reply)
Hi,
I have a requirement to capture file time stamp and compare with current system time. I am using HP-AUX K-shell.
Below is what i have done
Getting current date into myfile2
---------------------------------
date +%Y%m%d%H%M%S > myfile2
20091110132800
Getting the file date into... (5 Replies)
Hi all,
I have one libxxx.so file ( which I got from a third party ). We use shared library libxxx.sl . Is there any way to convert the .so file to .sl file ?
Thanks in advance
- M (3 Replies)
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)
Hello All,
I have a requirement to convert a 12 hour format to 24 hour time format and the sample input /out put is below
Input Time format : Nov 2 2011 12:16AM
Out Put Format : Nov 2 2011 0:16
Input : Nov 2 2011 4:16PM
Out Put: Nov 2 2011 16:16
I have done this using a... (6 Replies)
So, I'm into about 650 lines of some code I'm working on. So I'll try to explain instead of flooding this post. Say I have some code like this:
int main() {
int i, j;
char data;
printf("Gimme something: ");
fgets(data, INPUT_BUFF, stdin);
for (j = 0; j < data; j++){... (6 Replies)
Discussion started by: Azrael
6 Replies
LEARN ABOUT REDHAT
atoi
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)