double atof( const char *string );int atoi( const char *string );__int64 _atoi64( const char *string );long atol( const char *string );
解决方案 »
- 怎样获得editbox的值?谢谢
- 用 windows API 写了一个窗口,点关闭的时候窗口关了,程序 没有退出
- 问了半个月了,关于动态创建多个线程问题,来者有分!
- 怎么用api实现“点击menu里的命令,实现相应函数”WM_MenuSelect ?WM_MENUCOMMAND?
- 请问开发一套漂亮的界面控件要做哪些工作?
- 列举表中的所有字段、类型和长度,还差一点,请高手进来补充。
- 如何在VC++6.0中使用bios.h
- 使用ActiveMovie,如何自定义设置播放的尺寸..比如放大显示...一直没有解决,,,
- MFC中的注释问题
- vc能做DOS中使用的程序吗
- Windows 系统服务的信息输出
- vs.net中无法使用dbgrid??
* as strings can be converted to numeric values
* using the atof, atoi, and atol functions.
*/#include <stdlib.h>
#include <stdio.h>void main( void )
{
char *s; double x; int i; long l; s = " -2309.12E-15"; /* Test of atof */
x = atof( s );
printf( "atof test: ASCII string: %s\tfloat: %e\n", s, x ); s = "7.8912654773d210"; /* Test of atof */
x = atof( s );
printf( "atof test: ASCII string: %s\tfloat: %e\n", s, x ); s = " -9885 pigs"; /* Test of atoi */
i = atoi( s );
printf( "atoi test: ASCII string: %s\t\tinteger: %d\n", s, i ); s = "98854 dollars"; /* Test of atol */
l = atol( s );
printf( "atol test: ASCII string: %s\t\tlong: %ld\n", s, l );
}
Outputatof test: ASCII string: -2309.12E-15 float: -2.309120e-012
atof test: ASCII string: 7.8912654773d210 float: 7.891265e+210
atoi test: ASCII string: -9885 pigs integer: -9885
atol test: ASCII string: 98854 dollars long: 98854
转化成int时 如果成功那么也早就越界了
直接用 atoi就可以了
atoi是转换成int类型的
atol是转换成long类型的
:)