strtol()函数
#include <stdlib.h>
#include <stdio.h>
int main()
{
char a[] = "100";
char b[] = "100";
char c[] = "0x11";
int x, y, z;
x = strtol( a, NULL, 10 );
y = strtol( b, NULL, 2 );
z = strtol( c, NULL, 16 );
printf( "x = %d\n", x );
printf( "y = %d\n", y );
printf( "z = %d\n", z );
}
输出:x = 100
y = 4
z = 17
将字符串根据base转换为十进制整数
strtol()函数的更多相关文章
- strtol函数
今天做啦一个进制转换的题,改来改去最终倒是过啦,本来挺开心的,然后去翻啦一下题解,瞬间就有小情绪啦,哎,人家的代码辣么辣么短,实在是不开心,不过谁让咱是小渣渣呢,在此总结一下strtol 函数. 先来 ...
- strtol函数 将字符串转换为相应进制的整数
转自http://hi.baidu.com/qwpsmile/blog/item/9bc44efa4f41018a9f514637.html +----------------+| strt ...
- POJ1331 Multiply(strtol函数练习)
题目链接:http://poj.org/problem?id=1331 主要介绍strtol函数: long int strtol(const char *nptr,char **endptr,int ...
- 浅析C语言中strtol()函数与strtoul()函数的用法
转自:http://www.jb51.net/article/71463.htm C语言strtol()函数:将字符串转换成long(长整型数) 头文件: ? 1 #include <stdli ...
- strtol 函数用法
strtol是一个C语言函数,作用就是将一个字符串转换为长整型long,其函数原型为: long int strtol (const char* str, char** endptr, int bas ...
- strtol函数的用法——字符串转长整形
/* strtol example */ #include <stdio.h> /* printf */ #include <stdlib.h> /* strtol */ in ...
- string.h文件中函数用法
下面为string.h文件中函数的详细用法: strcpy函数名:strcpy功 能: 拷贝一个字符串到另一个用 法: char *strcpy(char *destin, char *source) ...
- C字符串处理函数
部分参考百科. C常用字符串函数:字符串输入函数,字符串输出函数,字符串处理函数,标准输入输出流 字符串处理函数: 1.字符串长度:strlen(str),返回字符串实际长度,不包括'\0',返回值类 ...
- strtol详解
文章装载自:http://blog.csdn.net/happylife1527/article/details/8441799,大家看到这篇文章想转载的请注明出处,尊重原作者劳动成果. 今天,在re ...
随机推荐
- python 调用 C++ code
本文以实例code讲解python 调用 C++的方法. 1. 如果没有参数传递从python传递至C++,python调用C++的最简单方法是将函数声明为C可用函数,然后作为C code被pytho ...
- 用任务管理器画CPU正弦曲线
这个最初是在microsoft的<编程之美>中看到的,用你的程序来控制CPU的使用率. 首先是要求写一个用来实现CPU使用率为50%程序. 这个还是很好实现的,只要让你的程序忙的时间课空闲 ...
- RTC系统【转】
http://blog.csdn.net/fanqipin/article/details/8089995 转自:http://www.cnblogs.com/muhuacat/p/5276306.h ...
- Java 异常 —— Bad version number in .class file
把一个项目拷贝到另一个环境,运行时报错: Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class ...
- centos6.5 中文
之前在网上查了不少资料,很多网友在网上都说,在shell命令下输入: # vi /etc/sysconfig/i18n 然后修改LANG="en_US.UTF-8" ...
- SQL Server Object Explorer in VS
菜单栏View-->SQL Server Object Explorer 默认有几个连接,可以根据需要自己再另外添加 比如添加127.0.0.1 建立连接之后,剩下的操作和sql server中 ...
- NHibernate 二级缓冲
session.CreateCriteria(typeof(SysModuleFields)).SetCacheable(true).List<SysModuleFields>(); se ...
- content management system
Defination of CMS: The definition of a CMS is an application (more likely web-based), that provides ...
- Qt之模式、非模式、半模式对话框
简述 关于"模式"和"非模式"对话框,相信大家都比较熟悉,但其中有一个可能很多人都比较陌生,介于两者之间的状态,我们称之为"半模式". 简述 ...
- linux下系统启动时,几个配置文件 /etc/profile、~/.bash_profile 等几个文件的执行过程,先后顺序
1. 在登录Linux时要执行文件的过程如下: 在刚登录Linux时, 首先启动 /etc/profile 文件, 然后再启动用户目录下的 ~/.bash_profile. ~/.bash_login ...