Quote:
Originally Posted by SickAttack
You can use valstr to convert an integer to a string.
"new digit" should be out of the loop
the function is just ridiculous
|
I respected the function header he provided in his post, where number was an integer, not a string. Also, this code is just a snippet I wrote in 2 minutes, based on a simple algorithm, sorry for not having enough time to optimize the hell out of it, even if these micro optimizations have little to no impact in reality.
However, if we're at this subject, then your function is not that bright, too:
- you don't check anywhere if array used to store the counter is large enough
- function would return invalid results for negative numbers
- instead of creating a 2 cell string, copying every character to that string, and then converting it to a number, you could have done something like this instead: "array[(string[i]-'0')] ++;"
- should I bring into discussion the differencies between pre- and post- increments? nah
So, why is my function ridiculous?