I would just take it one step at a time. Implement the part that counts all the bytes in the file, then do the part with the average number of symbols, then do the part that involves comments. In order to understand the problem, pick a C file that is representative of the input, and get your program to do each part.
As you build each part you can add it to a menu. Menu's usually use switches that call separate functions to work. When you're all done, you might end up with something like:
Code:
option = GetOption();
while (option != EXIT_OPTION)
{
switch (option)
{
case COUNT_OPTION: CountBytes( file );
break;
case AVG_OPTION: FindAverageTokens( file );
break;
case COMMENT_OPTION: SymbolsInComments( file );
break;
}
option = GetOption();
...
}
return 0;
The part that counts all the bytes should be the easiest since all you probably need to do to pass is count the number of characters in the whole file and display that. Other tasks aren't as clear. You definitely need to know what tokens are before you try to compute some sort of average, and you need to know which symbols matter in the comments.
For the comment part, the hard part is knowing that you're inside a comment. In the file, look for '/' and then '*', then you know you're in a comment. Set a flag, and get to work looking for a symbol. When you find '*' followed by '/', you will be out of the comment, so you need to set the flag back to normal. (The flag lets you know what kind of text you're looking for: symbols or comment tags)
Remember to take it one part at a time, and post if you have more questions or code problems.