Oct
04
2009

按字典序打印小于某值的自然数

execise

0
Oct
04
2009

非递归后序遍历二叉树

练习

0
Oct
04
2009

链表翻转code

经过简单测试

0
Jan
07
2006

关于va_start以及其他的一系列MACRO

关于va_start以及其他的一系列MACRO

2
Mar
01
2005

c函数两个(sscanf, sprintf)

int  sscanf ( char * buffer, const char * format [ , argument , ...] );
Read formatted data from string.  Reads data from the buffer specified and stores it into the locations given by argument(s). Locations pointed by each argument are filled with their corresponding type of value requested in the format string.  There [...]

2
Mar
01
2005

[zt]字符串:怎样转换字符串为数字类型?zz

字符串:怎样转换字符串为数字类型?
当将字符串转换为数值类型时, 有一项东西你不允许忽略:转换可能因为你正在转换的字符串可能不包含有效的数字表示法而失败
例如, 如果你想将"Hello"转换为数字, 转换将失败
老的C方法(不赞成)
许多人用atoi(), atof() 和这个“家族”中的其它函数. 它们方便应用,但是有一个重要的缺点: 在转换失败和转换字符串"0"时都返回0, 这样使得一致性错误检查变得几乎不可能。 为了完整性我们给出了小段代码:
 
代码:——————————————————————————–   const char* str_int = "777";   const char* str_float = "333.3";   int i = atoi(str_int);   float f = atof(str_float);——————————————————————————–
一个更好的办法:
更有一点复杂, 更遗一致的办法是利用sscanf()
代码:——————————————————————————–   const char* str_int = "777";   const char* str_float = "333.3";   int i;   float f;   if(EOF == sscanf(str_int, "%d", &i)){      //错误   }   if(EOF == sscanf(str_float, "%f", &f)){      [...]

0
Feb
28
2005

[zt]让C/C++图形程序独立运行

让C/C++图形程序独立运行

0