Thread: how to develop so many different solutions?

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    94

    how to develop so many different solutions?

    The C Programming Language Exercise 3-1

    Simply I dont now how? Please help me...

    To memorize all of them doesnt work... they will be gone after one week

    What would you suggest?

    Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Use those exercises for practice, not for rote learning. With practice, you will remember some things, and much of the rest can just be looked up when necessary. It is more important to understand the concepts so you can apply them in other related situations; there are only so many existing solutions that you can regurgitate.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by c_lady View Post
    To memorize all of them doesnt work... they will be gone after one week
    Me personally, I like to write short (as short as possible) demo programs for new concepts (K&R appears to encourage this), and keep them all loosely organized in my "C code" directory tree. I know how I think (sort of ) so I put in little helpful comments, for myself. Also, I find code I wrote easier to read than code anyone else wrote.

    If you do something a bunch of times, you will start to remember it. Short of that, I wouldn't expect to remember how to write a binary search because I did it once in an exercise. But if I kept my little demo with notes, then it probably won't take me long. The short demo is usually much easier to follow when you need your memory refreshed than going, "Oh, I remember I did that once in that other program which is 1000 lines...". IMO, trying to learn a new technique by coding it straight into your current project is a very very bad idea. Abstract and simplify instead, it saves time and frustration.

    As they say, there's no substitute for experience I guess.
    Last edited by MK27; 03-25-2010 at 11:17 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by MK27 View Post
    Me personally, I like to write short (as short as possible) demo programs for new concepts (K&R appears to encourage this), and keep them all loosely organized in my "C code" directory tree. I know how I think (sort of ) so I put in little helpful comments, for myself.
    Me too. I usually (when I remember ) start each source file with a one line comment. Then I use my own little ls script which displays all .c files in a folder and the first line.

    Code:
    for file in *.c ; do echo "   "$file ; head -n 1 $file ; echo "" ; done

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    94
    Very good comments quite impressive what I am hearing from subsonics! Maybe you should patent this kind of solution (scripting)

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Lol, I'm sure it's a pretty common practice. It is quite useful however.

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Yeah, that is a clever one.

    grep is a very great tool in this sense too, if you are looking for a particular command or lib function. Which of course you could pipe head into grep there.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to develop good logic in C language
    By rocky in forum C Programming
    Replies: 3
    Last Post: 02-19-2006, 08:52 AM
  2. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 06:16 AM
  3. #Develop Question, How do i create multiple Windows?
    By Zeusbwr in forum C# Programming
    Replies: 0
    Last Post: 04-24-2005, 11:14 AM
  4. Replies: 0
    Last Post: 05-19-2004, 06:11 AM
  5. Solutions for slow performance?
    By Hunter2 in forum Game Programming
    Replies: 52
    Last Post: 08-24-2002, 10:04 AM