作者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