int lfttrm(char* str) {
int len = 0; char* tmp; len = (int)strlen(str); if(0 == len) return len; tmp = str; while(len > 0){ if(0x20 == *tmp){ tmp++; len--; } else if(len > 1){ if((char)0x81 == *tmp && (char)0x40 == *(tmp+1)){ tmp += 2; len -= 2; } else break; } else break; } strcpy(str, tmp); return len;
} int rgttrm(char* str) {
int len; char* tmp; len = (int)strlen(str); if(0 == len) return len; tmp = str+len-1; while(len > 0){ if(0x20 == *tmp){ *tmp = '\0'; tmp--; len--; } else if(len > 1){ if((char)0x40 == *tmp && (char)0x81 == *(tmp-1)){ *tmp = '\0'; *(tmp+1) = '\0'; tmp -= 2; len -= 2; } else break; } else break; } //strcpy(str, tmp); return len;
} char *strtrm(char* str) {
int len; char ch; lfttrm(str);
rgttrm(str); return str;
}