سؤال

I need to parse a document in C language. I was about to use the strtok function but I don't know if it's the best method or if just a token system is enough (searching for \n, space etc).

The structure of each line of the document is : element \n element "x".

thanks :-)

هل كانت مفيدة؟

المحلول

Token system if fine, strtok is just an implementation of that. However, you're better off with using strtok_r which does not keep any internal state outside control of your program.

نصائح أخرى

I don't remember the details, but I saw in several sources that strtok was an unsafe piece of work. You'd be better off rolling your own, if you ask me.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top