C language implementation trim function