String manipulation and scanf vs fgets
First time on the board and I would like to say I've been enjoying meself reading many of the posts that I have found here. I would like to start off by saying that I did use the search feature before this question was asked :)
A little background on my project: I have to implement a double-linked list (which is done). After the double-linked list is implemented I have to create a structure to keep track of each double-linked list I create by name (partially done, just coded it to be a single-linked list pointing to each double-linked list).
Anways, the user is allowed to type in commands to interact with each double-linked list that is created, by name.
** commands **
d x s - delete the string x in list s.
pb s - print the contents of s in reverse alphabetical order.
** commands **
I read all about scanf and how inefficient it is and started using fgets, which does indeed get all of my input from each line without me having to flush the stdin or do any other 'magic'.
How would I get d into a variable named, userCommand? x into another one, and s...?
My problem starts with having to separate each string from the line of input. I found a post that referred me to: strpbrk(.., ..) (http://www.rt.com/man/strpbrk.3.html). I don't think strpbrk is exactly what I need. Since I'm dealing with a dynamic number of characters in my input fields I just can't do it by array indexes into the string. Any help is appreciated.