字符串提取数字
完成函数
void take_num(const char *strIn, int *n, unsigned int *outArray)
如输入
strIn="ab00cd+123fght456-25 3.005fgh"
输出
n=6
outArray={ 0, 123, 456, 25, 3, 5 }
不考虑小数如3.005输出3和5
题目分析:将字符串转换成uint,按公式temp=0;temp=temp*10;temp+=str[i]-'0';一直循环。
对于一个数,如果前面是0的话,那么按上面公式也会把0去掉的,也就是会从第一个非零的数开始计数。比如005,temp=0;temp=temp*10(temp=0);temp+=str[i]-'0'(temp=0);当i=i+1时,
按上面过程计算,仍然有temp=0,直到第一个非零的数字出现,这也正符合数的形式。
#include <string.h>
#include <stdio.h>
#include <assert.h>
void take_num(const char *strIn, int *n, unsigned int *outArray)
{
assert(s