Remove the space at both ends of the string trimSpace
There is a string with n spaces ("abcdefgdddd") at the beginning or end. To remove the leading and trailing spaces, a new string is returned.
Int trimSpace (char * bufscr, char * bufdes) {int I = 0; char * p = bufscr; // pointer variable, in order not to modify the incoming pointer int len = strlen (bufscr); int j = len-1; int count; // non-null character length int ret = 0; // first determine whether the passed pointer is NULL if (bufscr = NULL | bufdes = NULL) {ret =-1; printf ("func trimSpace err % d :", ret); return ret;} while (isspace (p [I]) & p [I]! = '\ 0') {I ++;} while (isspace (p [j]) & j> 0) {j --;} count = j-I + 1; memcpy (bufdes, p + I, count); // You must note that the difference between a string array and a string is that the string array ends with multiple \ 0' characters '. Bufdes [count] = '\ 0'; return ret ;}