// crt_atof.c
#include <stdlib.h>
#include <stdio.h>int main( void )
{
char *s; double x; int i; long l; s = " -2309.12E-15"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x ); s = "7.8912654773d210"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x ); s = " -9885 pigs"; /* Test of atoi */
i = atoi( s );
printf( "atoi test: \"%s\"; integer: %d\n", s, i ); s = "98854 dollars"; /* Test of atol */
l = atol( s );
printf( "atol test: \"%s\"; long: %ld\n", s, l );
}
结果:
atof test: " -2309.12E-15"; float: -2.309120e-012
atof test: "7.8912654773d210"; float: 7.891265e+210
atoi test: " -9885 pigs"; integer: -9885
atol test: "98854 dollars"; long: 98854觉得C++太好了,Delphi就是比不上。
#include <stdlib.h>
#include <stdio.h>int main( void )
{
char *s; double x; int i; long l; s = " -2309.12E-15"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x ); s = "7.8912654773d210"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x ); s = " -9885 pigs"; /* Test of atoi */
i = atoi( s );
printf( "atoi test: \"%s\"; integer: %d\n", s, i ); s = "98854 dollars"; /* Test of atol */
l = atol( s );
printf( "atol test: \"%s\"; long: %ld\n", s, l );
}
结果:
atof test: " -2309.12E-15"; float: -2.309120e-012
atof test: "7.8912654773d210"; float: 7.891265e+210
atoi test: " -9885 pigs"; integer: -9885
atol test: "98854 dollars"; long: 98854觉得C++太好了,Delphi就是比不上。
解决方案 »
- 如何在一个bpl中调用另一个bpl中的窗体
- dll窗体中的第三方皮肤控件无效!!
- 请问怎样才能让控件的caption里面的内容回车啊?
- delphi 关于C/S的问题
- ◆◆◆◆◆◆ 本人头一次见过这么多得好控件,不敢独享啊 ◆◆◆◆◆◆
- 急盼:dxTreeList中如何动态显示数据?
- 送分问题。管理连接本地的SQL SERVER服务器
- 请问如何得到DBGrid中生成行的行数?
- 您好,编程我刚接触,问一个问题
- treeview的使用
- 菜鸟问题 :一个用ADO连接SQL Server 2000数据库的问题,
- 用TWebBrowser.Navigate('c:\123.xls')打开后,如何用程序实现在Sheet间的跳转?
对于夹带字符的,本身就不能划作数字范畴,这个属于概念错误。
s = "98854 dollars"; /* Test of atol */
l = atol( s );
数字+字符,只转化字符?