This is a set of common functions for string and number processing.
更多...
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
|
static int | format_string (char *str) |
| This function examine whether a string represents a real number. 更多...
|
|
static double | str2num (char *number) |
| This function transform a string consisting '1', '2', ..., and '.' into the real number that it represents. 更多...
|
|
This is a set of common functions for string and number processing.
◆ format_string()
static int format_string |
( |
char * |
str | ) |
|
|
static |
This function examine whether a string represents a real number.
Transform the string represents a negtive number into a string represents a positive one and return its' sign. It returns 0 if the string do not represents a real number. After calling this function, there will be only one 'e' in the string, and the only position for '-' is behind 'e', and there can be only one dot in the string and the only position for it in before 'e'.
- 参数
-
[in] | str | String to be examined. |
- 返回
- The sign of the number represented by the string.
- 返回值
-
1 | Positive number. |
-1 | Negative number. |
0 | Not a number. |
- 弃用:
- This function has been replaced by the variable 'errno' in the standard Library <errno.h>.
◆ str2num()
static double str2num |
( |
char * |
number | ) |
|
|
static |
This function transform a string consisting '1', '2', ..., and '.' into the real number that it represents.
- 参数
-
[in] | number | String of the real number. |
- 返回
- The real number that the string represents.
- 弃用:
- This function has been replaced by the 'strtod()' function in the standard Library <stdio.h>.