I'm writing a program and part of it requires me to remove a bunch of spaces from the beginning of a string but still keep all the remaining characters.
Everything I've tried has given me completely empty strings as results.
Can anyone give me a code sample that will do this? Thanks.
I can't really use that one because the strings will not always have spaces at the start of the string, and there could be spaces later in the string. I only need to remove spaces from strings that begin with a space and then only the leading spaces.
The above code still works by finding the first non-space. If there is no first non-space, then the string is either empty or all whitespace, in either case of which the resulting string will be empty (which is what you want).