作者fairyflame (妖精火焰)
看板EE_DSnP
标题[问题] addHistory function
时间Sun Mar 30 23:06:36 2008
这个应该跟作业无关 我只是纯粹想知道code写的意义而已@__@"
在addhistory这个function里
// remove ' ' at the end
char* tmp = _readBufEnd - 1;
while ((tmp >= _readBuf) && (*tmp == ' ')) *(tmp--) = 0;
// remove ' ' in the beginning
tmp = _readBuf;
while (*tmp == ' ') ++tmp;
// add to _history
if (*tmp != 0) {
addHistoryStr(tmp);
_history[++_historySize].clear();
_historyIdx = _historySize;
}
在remove ' 'at the end里
*(tmp--) = 0;的意义到底是什麽呢@@?
是作为一个flag当add history时不要把它给加进去
那为什麽remove ' 'in the beginning 就不用令*(tmp)=0呢?
当判断式if (*tmp != 0)时 那其它原本输入若有0的字串不会有问题吗@@"
虽然跟作业不太有太大的关系 但还是想知道为什麽想这样写
恳请开示 谢谢<(_ _)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.235