精華區beta EE_DSnP 關於我們 聯絡資訊
bool CmdParser::moveBufPtr(char* const ptr) { if (ptr < _readBuf || ptr > _readBufEnd) { mybeep(); return false; } // move left while (_readBufPtr > ptr) { cout << char(BACK_SPACE_CHAR); --_readBufPtr; } // move right while (_readBufPtr < ptr) { cout << *_readBufPtr; ++_readBufPtr; } return true; } 這是老師給的其中一個function 其中move left的部份是cout << char(BACK_SPACE_CHAR); 我鍵盤上的BACK_SPACE_CHAR的ASCII是127 在cout BACK_SPACE_CHAR後會自動刪除一個字元.. 換句話說 照這樣設定時 我按下 ctrl-a (原先回到行首的程式碼) 整行就會被刪除 而原先作業上BACK_SPACE_CHAR 的 ASCII是8 是cursor往左移一位 我覺得教授的code指的應該是ASC 而非鍵盤上的BACK_SOACE_CHAR 是不是應該定義兩個enum... 一個是鍵盤上BACK_SPACE的按鈕 一個把cursor是往左移一個的ASCII code.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.251.102
ric2k1:I will reply your question in the next post. 10/22 01:04
ric2k1:If you still see a problem, please let me know. Thanks. 10/22 01:05
※ 編輯: Jyou 來自: 140.112.251.102 (10/22 09:59)