mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-15 11:20:05 +08:00
ignore non numeric characters when creating large_number from a string
This commit is contained in:
committed by
Krishna Vedala
parent
f4778612e0
commit
9b538f3783
@@ -48,7 +48,11 @@ public:
|
||||
large_number(const char *number_str) /**< initializer from a string */
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user