int my_atoi(const char *str)
{
assert(str != NULL);
int flag = ;
int result = ;
while(*str == ' ' || *str == '\n' || *str == '\t')
{
++str;
}
if(*str == '-')
{
flag = -;
++str;
}
else if(*str == '+')
{
++str;
}
while(*str != '\0')
{
if(*str >= '' && *str <= '')
{
result = result* + *str - '';
}
else
{
return flag * result;
}
++str;
}
return flag * result;
}

atol实现【转】的更多相关文章

  1. Linux下c++中的atoi、atol、atoll、atof函数调用实例

    本文中调用的四个函数如下: atoi函数:将字符串转化为int类型变量 atol函数:将字符串转化为long类型变量 atoll函数:将字符串转化为long long类型变量 atof函数:将字符串转 ...

  2. C++ atol

    函数名: atol 功 能: 把字符串转换成长整型数 用 法: long atol(const char *nptr);   简介编辑 相关函数: atof,atoi,strtod,strtol,st ...

  3. atol字符串转换函数应用实例

    原型:long atol(const char *nptr); 相关函数 atoi,atol,strtod,strtol,strtoul 头文件:stdlib.h 功能:将字符串转换成整型数 说明:参 ...

  4. atoi atol strtod strtol strtoul _gcvt

    如果以下函数,您在使用的时候,总是输出一个莫名的值,是因为您忘记了引用头文件 #include <stdlib.h> 1- atoi int atoi(const char *nptr); ...

  5. atof()函数 atol()

    atof()函数 atof():double atof(const char *str ); 功 能: 把字符串转换成浮点数 str:要转换的字符串. 返回值:每个函数返回 double 值,此值由将 ...

  6. [trouble shoot]atol和atoll

    就终于的结果来看,事实上就是一个小的错误. 但定位错误的时间比較漫长了.. . 背景:出错的代码是 一段执行在 linux server上的程序,程序的主要功能是处理银行pos刷卡记录并做一些计算.最 ...

  7. minix中atoi、atol、atof的实现

    在minix2.0源代码中,有将字符串类型转换为int.long.double类型的函数实现,相关的实现函数分别在atoi.c.atol.c.atof.c文件中,我们来逐一学习其中的源码: 1.int ...

  8. 字符串转换atof atoi atol gcvt strtod strtol strto ul toascii tolower toupper

    atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul 表头文件 #include <stdlib.h> 定义函数 double at ...

  9. 函数atof,atoi,atol,strtod,strtol,strtoul 描述

    函数atof,atoi,atol,strtod,strtol,strtoul atof(将字串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul表头文件 #in ...

  10. strtol函數的用法 atof, atoi, atol, strtod, strtoul

    相关函数: atof, atoi, atol, strtod, strtoul表头文件: #include <stdlib.h>定义函数: long int strtol(const ch ...

随机推荐

  1. Django学习笔记(12)——分页功能

    这一篇博客记录一下自己学习Django中分页功能的笔记.分页功能在每个网站都是必要的,当页面因需要展示的数据条目过多,导致无法全部显示,这时候就需要采用分页的形式进行展示. 分页在网站随处可见,下面展 ...

  2. Jena+fuseki

    1.下载apache-jena-3.1.0.tar.gz,这个可以将ttl三元组文件或者xml文件加载 进入bin目录,执行./tdbloader2 --loc /path/for/database ...

  3. SpringBoot中@EnableAutoConfiguration注解用法收集

    参考: http://blog.csdn.net/xiaoyu411502/article/details/52770723 https://docs.spring.io/spring-boot/do ...

  4. Android 学习之路和App开发框架

    学习之路: 1. http://www.stormzhang.com/android/2014/07/07/learn-android-from-rookie/ 框架: 2. https://gith ...

  5. zerorpc的安装

    1.简介及安装 rpc使构建分布式系统简单许多,在云计算的实现中有很广泛的应用 rpc可以是异步的 python实现rpc,可以使用标准库里的SimpleXMLRPCServer,另外zerorpc是 ...

  6. Sales Team 仪表盘

                实际设定值         仪表定义     <div class="oe_center" t-if="record.invoiced_ta ...

  7. Odoo 运费

    模块delievery可以将运费Charge给客户     安装delivery模块                 Delivery method     在做订单的时候,选择相应的运输方法, 系统 ...

  8. Objective-C中单例

    单例模式,由于其简单好用容易理解.同时在出问题时也容易定位的特点,在开发中经常用到的一个设计模式. 一般在程序中,经常调用的类,如工具类.公共跳转类等,我都会采用单例模式 这个写法是苹果推荐的写法   ...

  9. 【HDOJ 5654】 xiaoxin and his watermelon candy(离线+树状数组)

    pid=5654">[HDOJ 5654] xiaoxin and his watermelon candy(离线+树状数组) xiaoxin and his watermelon c ...

  10. D堆的实现

    实现上一篇博客(http://blog.csdn.net/buleriver/article/details/38469977)说的D堆.假设把mD设置成2.D堆就退化成二叉堆,也就是说.二叉堆是D堆 ...