In <200908202214.46288.drankinatty@suddenlinkmail.com>, David C. Rankin wrote:
Slightly OT, but if I read a text file into a single buffer, I can parse the buffer to find the number of lines by finding and counting the '\n' characters, but then how do I create a set of pointers (array, list, whatever) to the lines of text so I can access them?
I can use fmemopen, use the address of the buffer and then get the address of each '\n' and then add 1 to the pointer to get the start of the next line of text, but that just seems whacky.
Why does that seem whacky? There's no special BOL or EOL marker (other than '\n') in the file, so the only way to identify the lines is to find the '\n's. You could use different tools, but strchr or similar seems sufficient. You might want to build your "array, list, whatever" while you are counting the lines though. -- Boyd Stephen Smith Jr. ,= ,-_-. =. bss@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/