C语言 atol

C语言 atol

功能:将一个字符串转化为long类型

案例

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(void)
{
    // 字符类型
    // char ch[] = " -123456abc"; 只会打印数字、非数字停止
    char ch[] = "  -12.3456";
    // 转换类型
    long i = atol(ch);
    // 转换为long类型
    printf("%d\n", i);
    return 0;
}
atol 使用案例

 

posted @ 2020-02-28 19:10  kevin.Xiang  阅读(363)  评论(0编辑  收藏  举报