(2)不允許申請新的空間。
提醒後進行了更改):
remove_extra_space( * state = ; i = ; j = ; (; str[i] != ; ++ (str[i] == || str[i] == (state == || state == || state == (state == str[j++] = state = (str[i] == (state == || state == (state == str[j - ] = state = (state == str[j++] = state = str[j++] = state = (state == || state == -- str[j] = }
參照的思路和playerc的代碼更改為使用指針的版本(推薦):
remove_extra_space( * *sp = *prev = (*str && (*str == || *str == || *str == ++ (; *str; ++ (* : *str = (*prev == || *prev == (*prev == (*prev == *prev = prev = *sp++ = * (prev && *prev && (*prev == || *prev == -- *sp = }
參考playerc所寫代碼:http://www.cnblogs.com/playerc/p/3217355.html
最後,對所有提供寶貴意見的朋友表示感謝!