Welcome, Guest. Please login or register.

Author Topic: My C homework  (Read 16005 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Wain

  • Hero Member
  • *****
  • Join Date: Sep 2002
  • Posts: 745
    • Show all replies
Re: Mel's C homework
« on: February 26, 2007, 12:58:22 AM »
This looks like a really solid beginner implementation of such an idea.  

I would like to make a recommendation from my experience that you eventually may want to try to keep your program flow separate from your conditional code, while this is absolutely unimportant in a program as simple as your phase 1, keeping them together in phase 3 may result in a rather unwieldy bit of code that could wind up being difficult to read/follow by other programmers, or yourself 2 months later.

What I essentially mean by this is to put your switch statement into a separate function called something like is_whitespace();  to be called inside of your while-loop.  Of course, you would also need to mildly restructure the implementation of your solution to do something like this.


Also...
What you may want to try at a more advanced stage is to rewrite it so that it loads a large portion of the file (or all of it) into memory and then processes it from there.

If you were working on large text files it would inevitably save time and reduce disk access...beyond being a good way to get comfy with malloc and basic pointer work.



Regardless of all of this...you've done some really good work so far!  :-)  :-)  :-)


as far as phase 2 is concerned...
Don't forget to filter punctuation from your word-lengths.


Professional Expatriate