mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
ignore non numeric characters when creating large_number from a string
This commit is contained in:
parent
f4778612e0
commit
9b538f3783
@ -48,7 +48,11 @@ public:
|
|||||||
large_number(const char *number_str) /**< initializer from a string */
|
large_number(const char *number_str) /**< initializer from a string */
|
||||||
{
|
{
|
||||||
for (size_t i = strlen(number_str); i > 0; i--)
|
for (size_t i = strlen(number_str); i > 0; i--)
|
||||||
_digits.push_back(number_str[i - 1] - '0');
|
{
|
||||||
|
unsigned char a = number_str[i - 1] - '0';
|
||||||
|
if (a >= 0 && a <= 9)
|
||||||
|
_digits.push_back(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user