Personally, I would suggest a linked list container for this type of problem...anyway, there is no "simple" way, but to be brief, parsing, in general is something you need to master as a programmer. So spend a good two months hunkered down in a quiet spot and really put all your effort into it! The basic mechanism I use is a simple switching flag that works like a train switch, directing output as necessary. here's an example:
//count words in a string...
Code:
int CountWords(char str[], int len)
{
int i = 0, flag = 0, count = 0;
for( i = 0; i < len; i++ )
{
if(!isspace(str[i]))
{
if(!flag)
{
++count, flag = 1;
}
}
else
{
flag = 0;
}
}
return count;
}
...This is the basic switching mechanism that is used in parsing....
Play with it, and expand on it to fit your needs.
happy Coding