String handling woes with C

Someone asked about strtok and string.h, here's the reply.

© Guy Lecky-Thompson

Dec 1, 2006

String.h and strtok, an article, an opinion, and one use for it.


I notice in my search stats that readers have been looking for string token handling, and general calls to string.h, part of the standard C header files.

Since I've vowed to act on this kind of information, I decided to write a little piece about the strtok function. This can be used to tokenize strings in C, and is really quite handy. Not without it's caveats, however, principlally in the area of memory management.

If anyone has a nicer strtok implementation, that behaves in a similar fashion, but is somehow safer to use, then let me know. The article, by the way, looks at a very simple CSV cracker; this has to be one of the most common uses for strtok, so that's always a good place to start.

Here's the link. Enjoy!

String Tokenizing in C Programming


Post this Blog to facebook Add this Blog to del.icio.us! Digg this Blog furl this Blog Add this Blog to Reddit Add this Blog to Technorati Add this Blog to Newsvine Add this Blog to Windows Live Add this Blog to Yahoo Add this Blog to StumbleUpon Add this Blog to BlinkLists Add this Blog to Spurl Add this Blog to Google Add this Blog to Ask Add this Blog to Squidoo