✅ Trying to count numbers on a string
I want to count how many times any number appears in the string, in a way such that: "2" then numbers ++ and "351" then numbers++ every time any number appears, instead of counting the digits.
17 Replies
Iterate over each character in a string, add to an integer if that character matches the specified number.
I understood the first part of your question
But could you elaborate on the rest?
Yes, basically every time any number appears the counter goes +1
For instance +1 for 235
So the amount of addition is not determined by the digit itself
Instead of +3 for the digits
Exactly, any number, if it has three, one or any digits it just adds +1
What's separating these numbers in the string?
spaces
Can you explain it to me?
Pretty straightforward
We're splitting the string with a whitespace splitter
Oh I forgot, I cant use Split
Why is that?
My teacher wont allow functions he hasnt taught us
Then create your own Split function
The fact I wrote this on my phone
What is tempStr?
A temporary string
We havnt seen that either
Dude it's just a string