`
Poechant
  • 浏览: 212685 次
博客专栏
Bebe66e7-3a30-3fc9-aeea-cfa3b474b591
Nginx高性能Web服务...
浏览量:23518
5738817b-23a1-3a32-86de-632d7da73b1e
Cumulus实时媒体服务...
浏览量:21426
社区版块
存档分类
最新评论

[Cexpert-001] How to implement atoi with least codes using C language?

 
阅读更多

It's soooo easy, I think.


#include <stdio.h>

int atoi(unsigned char *str)
{
   int num = 0;
   while (*str >= '0' && *str <= '9') num = num * 10 + *str++ - '0';
   return num;
}

int main(void)
{
   printf("%d\n", atoi("12345"));
   return 0;
}

So easy, right?

-

Poechant

-

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics