c htoi
来源:互联网 发布:有了源码如何建站 编辑:程序博客网 时间:2024/06/06 20:29
/* * The C Programming Language, second edition, * by Brian Kernighan and Dennis Ritchie * * Exercise 2-3, page 46 * * Write the function htoi(s), which converts a string of hexadecimal * digits (including an optional 0x or 0X) into its equivalent integer * value. The allowable digits are 0 through 9, a through f, and A * through F. *//* htoi: convert hexdicimal string s to integer */int htoi(char s[]){ int i; int c, n; n = 0; for (i = 0; (c = s[i]) != '\0'; ++i) { n *= 16; if (i == 0 && c == '0') { /* Drop the 0x of 0X from the start of the string. */ c = s[++i]; if (c != 'x' && c != 'X') --i; } else if (c >= '0' && c <= '9') /* c is a numerical digit. */ n += c - '0'; else if (c >= 'a' && c <= 'f') /* c is a letter in the range 'a'-'f' */ n += 10 + (c - 'a'); else if (c >= 'A' && c <= 'F') /* c is a letter in the range 'A'-'F' */ n += 10 + (c - 'A'); else /* invalid input */ return n; } return n;}
0 0
- c htoi
- htoi函数
- htoi(十六进制转十进制)
- 面试经典题目 atoi实现 htoi实现
- 从0开始<五>:字符串相关-htoi函数,删除字符串中指定字符
- 练习2-3 编写函数htoi(s),把由十六进制数字组成的字符串(包含前缀0x或0X)转换成与之等价的整型值
- 练习2-3 编写函数htoi(s),把由16进制数字组成的字符串(包含可选的前缀0X或0x)转换成与之等价的整形值。字符串中允许包含的数字包括:0 ~ 9, a ~ f,A ~ F。
- 练习 2-3 编写函数 htoi(s),把由十六进制数字组成的字符串(包含可选的前缀 0x 或 0X)转换为与之等价的整型值。字符串中允许包含的数字包括:0~9、a~f 以及 A~F。
- 练习2-3 编写函数 htoi(s),把由十六进制数字组成的字符串(包含可选的前缀0x 或0X)转换为与之等价的整型值。字符串中允许包含的数字包括:0~9、a~f以及A~F。
- 练习2-3 编写函数 htoi(s),把由十六进制数字组成的字符串(包含可选的前缀0x或0X)转换为与之等价的整型值。字符串中允许包含的数字包括:0~9、a~f以及A~F。
- 练习 2-3 编写函数 htoi(s),把由十六进制数字组成的字符串(包含可选的前缀 0x 或 0X)转换为与之等价的整型值。字符串中允许包含的数字包括:0~9、a~f 以及 A~F。
- c
- c
- c
- c
- C
- c
- c
- Solr索引增删改查
- oj学生数组
- Ural 1519. Formula 1 优美的插头DP
- zookeeper的领导者选举和原子广播
- Object Literals(提供了很棒的语法糖)
- c htoi
- C#中的关键字学习:delegate(委托)和volatile
- 学习理论和动手实践
- 面试杂题(七)二维数组中寻找
- POJ 2362 Square(DFS回溯构造)
- highcharts图表高级入门之polar:极地图的基本配置以及一些关键配置说明(转载)
- Android WebView 与HttpClient 共用本地cookie问题
- 加快冯就卡而后士大夫人体后熬过
- Java Socket实战之六 使用NIO包实现Socket通信