ATOI的用法

本文详细介绍了atoi、atol、atoll及atoq等函数的功能,这些函数用于将字符串转换为整数类型。文章解释了它们如何工作,并给出了各自的原型定义,同时指出了不同函数之间的差异及其返回值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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()  func-
       tion  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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值