作者lg31cm (我住5F)
看板Programming
標題Re: [問題] 字串比較的問題
時間Tue Feb 20 13:53:18 2007
※ 引述《[email protected] (㊣祕密情報員)》之銘言:
: ※ 引述《[email protected] (哼!)》之銘言:
: > 譬如說C的compiler或是接收指令(RS232, Internet)來做相對應的事情
: > 如果指令的格式是int或是其他可以轉成int的type
: > 就可以用switch case來做...
: > 但是如果是字串...switch case不支援字串...(C,C++,Java)
: 把關鍵字轉換成整數,然後利用整數做switch.
: 這就是lex的用處。lex裡面則是用state machine做的。
:
幹嘛那麼麻煩,用 STL 的 std::map 配合 string 就可以
做出同樣的效果,或者用 SGI STL 的 hash_map 也可以做出同樣
的效果
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.124.101.171