Tokenizing a string (since strtok() appears to be deprecated)
Posted on 2004-09-18
Okay, first off, this question *is* related to a homework assignment, however it's not the main thrust of it -- the assignment is to write a rudimentary analogue of gdb for a toy VM for an operating systems course. That being said, if anyone doesn't want to answer on the basis of the preceding, feel free.
Anyway, as part of the debugger, I'm needing to parse commands entered by the user. What I need is to take a string and get two things out of it.. essentially argc and argv. So, since every manpage on the subject says "Don't use strtok!!!" what are the alternatives, and how should I go about getting all of this info? The text is going to be a series of integer values separated by spaces. Anything else should allow me to spit out an error.
I just want to reiterate that this is *not* the assignment, this is a small part of it, and the rest is the hard part -- which I'm doing myself. Please don't chew me out over this :)