Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C, strtok

Name: Anonymous 2010-02-16 13:01

Hello /prog/

Could anyone help me with using the C function strtok and strtok_r?

I've read the man pages and it doesn't provide much help. Try compiling this code example gotten from the man pages:

http://pastebin.com/d11d44ccf

Name: Anonymous 2010-02-16 13:14

strtok is a horribly unsafe function. It uses an internal static variable to keep the state. It would be much safer if it returned a structure to keep the state, or you used an object or (pseudo-)closure (since C doesn't have native support for them, but it's easy to emulate them) to do the same thing. If you still want to use strtok, then doing it that way is okay too. What exactly don't you understand about it?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List