How can I take a string (in this case it'll be loaded from a file) then remove certain characters and store them in an array.
Ex:
f.e.d.r.t.g.f
remove "." to get f e d r t g f in an array where I can manipulate each individually
How can I take a string (in this case it'll be loaded from a file) then remove certain characters and store them in an array.
Ex:
f.e.d.r.t.g.f
remove "." to get f e d r t g f in an array where I can manipulate each individually
You can loop over them, if the character is rejected go to next character (or return if no more chacters). If it is not rejected push it into the array. That would create a copy of the characters, but unless your string is gigantic it is not a problem. If it is, my answer wont suffice :)
Another variant would be a function that reads the string until it hits a valid character and returns it. To get the next character call the function again. The function needs to maintain an index variable passed to it though. If the end of the string is reached you would need to indicate it somehow.
Just iterate through the string and only copy the characters you're interested in, maintaining an index of the current position in the new array.
strtok() does this easily if