替换空格
void replace(char* data, int length) { if (data == nullptr || length <= 0) return; int nEmptyNumber = 0; int nOrignialLength = 0; int i = 0; while(data[i] != '\0') { if(data[i] == ' ') ++nEmptyNumber; ++i; ++nOrignialLength; } int nReplaceLength = nOrignialLength + nEmptyNumber * 2; if (nReplaceLength <= nOrignialLength || nReplaceLength > length) return; int nIndexReplace = nReplaceLength; while (i >= 0 && nIndexReplace > i) { if (data[i] == ' ') { data[nIndexReplace--] = '0'; data[nIndexReplace--] = '2'; data[nIndexReplace--] = '%'; } else data[nIndexReplace--] = data[i]; --i; } return; }