1. Re: optimization
- Posted by David Cuny <dcuny at LANSET.COM> Jun 12, 1998
- 606 views
- Last edited Jun 13, 1998
Andy Kurnia suggested instead of: >> c = fn >> while c != -1 do >> c = getc(fn) >> r = r&c >> end while to use: > if fn != -1 then > c = getc(fn) > while c != -1 do > r = r & c > c = getc(fn) > end while > end if That used to be my approach, until I saw Robert's example in the manual for 'gets'. His logic is more like: while 1 do c = getc(fn) if c = -1 then exit end if r = r & c end while So I assume this is the "preferred" idiom. -- David Cuny