小白教程
所有教程
关于
Search
172.70.100.191
172.70.100.191
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“C function atol”的源代码
本页内容
上一节:
C_function_atoi
下一节:
C_function_strtod
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:long int atol(const char *str)}}[[Category:c standard library stdlib h|3]] = C 库函数 - atol() = [[c standard library stdlib h|C 标准库 - <stdlib.h>]] == 描述 == C 库函数 '''long int atol(const char *str)''' 把参数 '''str''' 所指向的字符串转换为一个长整数(类型为 long int 型)。 == 声明 == 下面是 atol() 函数的声明。 <pre> long int atol(const char *str) </pre> == 参数 == * '''str''' -- 要转换为长整数的字符串。 == 返回值 == 该函数返回转换后的长整数,如果没有执行有效的转换,则返回零。 下面的实例演示了 atol() 函数的用法。 <pre> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { long val; char str[20]; strcpy(str, "98993489"); val = atol(str); printf("字符串值 = %s, 长整型值 = %ld\n", str, val); strcpy(str, "xiaobai.wang"); val = atol(str); printf("字符串值 = %s, 长整型值 = %ld\n", str, val); return(0); } </pre> 让我们编译并运行上面的程序,这将产生以下结果: <pre> 字符串值 = 98993489, 长整型值 = 98993489 字符串值 = xiaobai.wang, 长整型值 = 0 </pre> [[c standard library stdlib h|C 标准库 - <stdlib.h>]]
返回至“
C function atol
”。
上一节:
C_function_atoi
下一节:
C_function_strtod