Write a C program to trim leading white space characters from a given string using loop. Note, if only spaces need to be removed, PureBasic provides commands that do this: Made gratuitous use of things like strlen that pre-iterate the entire string. We can find the first non-whitespace character position trivially:. There is no memory being allocated, so there is no memory to free. FCTX -based unit tests included.
There's nothing inherently wrong with returning a different address from the one that was passed in.
Have you given thought to more of an in-place approach? I just fixed the code. Then, we allocate a character array with that size and taking care of the null terminated character. The function strip can be very useful when used in conjunction with conditionals. Now string starts from char which is not a space char or any other white char. Thanks, I never realized that was necessary.