编程实现atoi函数
来源:互联网 发布:网店优化方案 编辑:程序博客网 时间:2024/05/19 13:43
#include <stdio.h> #include <string.h> #define MAX_SIZE 100 int my_atoi(char *src) { int flag = 1; int result = 0; if(*src == '-') { flag = -1; src++; } while(*src != '\0') { if(*src >= '0' && *src <= '9') { result = result * 10 + (*src - '0'); } else { break; } src++; } return result * flag; } int main() { int i; int len; int result = 0; char src[MAX_SIZE] = {0}; printf("Please input string:\n"); gets(src); result = my_atoi(src); printf("result = %d\n",result); return 0; }
0 0
- 编程实现atoi()函数
- 编程实现atoi函数
- 编程实现C函数 atoi atof
- atoi函数实现
- atoi,itoa函数实现
- atoi函数的实现
- atoi()函数的实现
- atoi函数实现
- atoi函数实现
- atoi函数实现
- atoi函数实现_buwanmei
- 实现atoi函数
- atoi函数实现
- atoi()函数的实现
- atoi函数的实现
- atoi函数的实现
- atoi函数实现
- atoi函数实现
- 灵活而奇特的C++语言特性——const(三)
- leetcode-448 Find All Numbers Disappeared in an Array
- 粗略列出并理解Java中的IO
- Swing
- Android中的原型模式
- 编程实现atoi函数
- TensorFlow在Windows10中的安装
- 【解题报告】Codeforces Round #340 (Div. 2)
- The Template method pattern
- #define与typedef的区别
- 野指针
- The Strategy pattern
- python线程、进程
- Scale-Dependent 3D Geometric Features