How to improve C skill?

Discussion in 'C Programming' started by weidongtom@gmail.com, May 10, 2007.

  1. Guest

    Hi,

    I have just finished reading some tutorials on C, I am wondering how I
    could improve my skill. Is there any advice? Is reading others' codes
    the best way? If so, what type of codes are suitable for novice? The
    ones in fsf freed software directory? I have been reading quite a few
    books on the programming language C, but when I tried to start a
    project of my own, I find myself to be incompetent. What should I do?
    Thanks in advance.
    , May 10, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > Hi,
    >
    > I have just finished reading some tutorials on C, I am wondering how I
    > could improve my skill. Is there any advice?


    Plenty!

    > Is reading others' codes
    > the best way? If so, what type of codes are suitable for novice?


    Code in this context is singular ("code" rather than "codes"). Just
    reading code probably isn't a good idea. Reading source to see how
    something you know works is more effective.

    Try the exercises in K&R, there have been plenty of solutions posted
    here to look through if you get stuck.

    > I have been reading quite a few
    > books on the programming language C, but when I tried to start a
    > project of my own, I find myself to be incompetent. What should I do?


    Start simple!

    --
    Ian Collins.
    Ian Collins, May 10, 2007
    #2
    1. Advertising

  3. <> wrote in message
    news:...
    > Hi,
    >
    > I have just finished reading some tutorials on C, I am wondering how I
    > could improve my skill. Is there any advice? Is reading others' codes
    > the best way? If so, what type of codes are suitable for novice? The
    > ones in fsf freed software directory? I have been reading quite a few
    > books on the programming language C, but when I tried to start a
    > project of my own, I find myself to be incompetent. What should I do?
    > Thanks in advance.
    >

    Try writing "asteroids".
    This is a game in which you manoevre a spacship between lines of asterisks,
    which scroll down the console. You will need curses / conio or other
    non-standard header to treat the console correctly.
    It is very easy to write and will give you a sense of achievement. It you
    put in levels and scores you can make quite a sophisticated game.
    Start by making sure you can use your console library to position characters
    at will.
    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
    Malcolm McLean, May 10, 2007
    #3
  4. said:

    > Hi,
    >
    > I have just finished reading some tutorials on C, I am wondering how I
    > could improve my skill. Is there any advice? Is reading others' codes
    > the best way?


    Crank up the warning level of your compiler as high as it will go, and
    write lots and lots of programs. Remember that much of what your
    tutorials taught you is likely to be wrong. Most C tutorials are
    written by people who don't know C. Come to think of it, so is most C
    code. So, whilst "reading others' code" can be helpful, get into the
    habit of thinking "why is this code bad? What don't I like about it?
    What diagnostic messages does it cause my compiler to emit? Do I
    understand those messages? What don't I understand about the code
    itself? *WHY* is the author doing such-and-such?"

    > I have been reading quite a few
    > books on the programming language C, but when I tried to start a
    > project of my own, I find myself to be incompetent.


    Honesty will get you everywhere! :) Seriously, true competence (in
    *any* field worth pursuing) takes about ten years of diligent study and
    *practice*. Ten years to be a competent doctor, lawyer, programmer,
    whatever.

    Devise a project of your very own - e.g. a simple text processor - and
    define N things you'd like it to do (where N is initially at least 4).
    Implement those features, one at a time, learning all about diagnostic
    messages as you go! When you've implemented all N features, think up
    another N/4 features (rounded down), and notice how awkward it is to
    fit them in. Re-factor the code to make adding the new features much
    more pleasant, and now you're starting to learn about programming. Once
    all 5N/4 features are implemented, let N = 5N/4 and go round again,
    until you start to hit practical limits. This is feature creep with a
    vengeance! But it will introduce you gently to large programs.

    > What should I do?


    Write C programs.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
    Richard Heathfield, May 10, 2007
    #4
  5. jaysome Guest

    On 9 May 2007 19:57:02 -0700, ""
    <> wrote:

    >Hi,
    >
    >I have just finished reading some tutorials on C, I am wondering how I
    >could improve my skill. Is there any advice? Is reading others' codes
    >the best way? If so, what type of codes are suitable for novice? The
    >ones in fsf freed software directory? I have been reading quite a few
    >books on the programming language C, but when I tried to start a
    >project of my own, I find myself to be incompetent. What should I do?
    >Thanks in advance.


    Buy the book "C Programming FAQs: Frequently Asked Questions", and
    read it cover to cover. This book is written by Steve Summit, who
    wrote the FAQ for this newsgroup. The book is available on amazon.com:

    http://www.amazon.com/Programming-FAQs-Frequently-Asked-Questions/dp/0201845199

    Additionally, continue to read this newsgroup. There are some really
    sharp people who post here, and if you lurk around here for a
    reasonable amount of time, you should be able to determine who these
    people are, and learn a lot from them.

    Also, get yourself a cheap PC ($100 U.S.) at a garage sell or on your
    local classifieds and install a free Linux distribution like Ubuntu:

    http://www.ubuntu.com/

    Linux distributions will provide you with the gcc compiler, which is
    arguably one of the best available, free or not. Just make sure to
    write a lot of programs and crank up the compiler warning level. For
    example, with gcc, this is a good start:

    gcc -Wall -W -ansi -pedantic

    Finally, if you have any questions about standard C, don't hesitate to
    ask in this newsgroup.

    Best regards
    --
    jay
    jaysome, May 10, 2007
    #5
  6. jaysome wrote:
    > On 9 May 2007 19:57:02 -0700, ""
    > <> wrote:
    >
    >> Hi,
    >>
    >> I have just finished reading some tutorials on C, I am wondering how I
    >> could improve my skill. Is there any advice? Is reading others' codes
    >> the best way? If so, what type of codes are suitable for novice? The
    >> ones in fsf freed software directory? I have been reading quite a few
    >> books on the programming language C, but when I tried to start a
    >> project of my own, I find myself to be incompetent. What should I do?
    >> Thanks in advance.

    >
    > Buy the book "C Programming FAQs: Frequently Asked Questions", and
    > read it cover to cover. This book is written by Steve Summit, who
    > wrote the FAQ for this newsgroup. The book is available on amazon.com:
    >
    > http://www.amazon.com/Programming-FAQs-Frequently-Asked-Questions/dp/0201845199
    >
    > Additionally, continue to read this newsgroup. There are some really
    > sharp people who post here, and if you lurk around here for a
    > reasonable amount of time, you should be able to determine who these
    > people are, and learn a lot from them.
    >
    > Also, get yourself a cheap PC ($100 U.S.) at a garage sell or on your
    > local classifieds and install a free Linux distribution like Ubuntu:
    >
    > http://www.ubuntu.com/
    >
    > Linux distributions will provide you with the gcc compiler, which is
    > arguably one of the best available, free or not. Just make sure to
    > write a lot of programs and crank up the compiler warning level. For
    > example, with gcc, this is a good start:
    >
    > gcc -Wall -W -ansi -pedantic


    Since beginners are often satisfied when the compilation ends without
    errors but with many warnings, I would add -Werror ;-)

    a+, ld.
    Laurent Deniau, May 10, 2007
    #6
  7. jaysome wrote:
    > On 9 May 2007 19:57:02 -0700, ""
    > <> wrote:
    >
    >> Hi,
    >>
    >> I have just finished reading some tutorials on C, I am wondering how I
    >> could improve my skill. Is there any advice? Is reading others' codes
    >> the best way? If so, what type of codes are suitable for novice? The
    >> ones in fsf freed software directory? I have been reading quite a few
    >> books on the programming language C, but when I tried to start a
    >> project of my own, I find myself to be incompetent. What should I do?
    >> Thanks in advance.

    >
    > Buy the book "C Programming FAQs: Frequently Asked Questions", and
    > read it cover to cover. This book is written by Steve Summit, who
    > wrote the FAQ for this newsgroup. The book is available on amazon.com:
    >
    > http://www.amazon.com/Programming-FAQs-Frequently-Asked-Questions/dp/0201845199
    >
    > Additionally, continue to read this newsgroup. There are some really
    > sharp people who post here, and if you lurk around here for a
    > reasonable amount of time, you should be able to determine who these
    > people are, and learn a lot from them.
    >
    > Also, get yourself a cheap PC ($100 U.S.) at a garage sell or on your
    > local classifieds and install a free Linux distribution like Ubuntu:
    >
    > http://www.ubuntu.com/
    >
    > Linux distributions will provide you with the gcc compiler, which is
    > arguably one of the best available, free or not. Just make sure to
    > write a lot of programs and crank up the compiler warning level. For
    > example, with gcc, this is a good start:
    >
    > gcc -Wall -W -ansi -pedantic

    Why would you use -ansi instead of -c99?

    >
    > Finally, if you have any questions about standard C, don't hesitate to
    > ask in this newsgroup.
    >
    > Best regards



    --
    Pietro Cerutti

    PGP Public Key ID:
    http://gahr.ch/pgp
    Pietro Cerutti, May 10, 2007
    #7
  8. Pietro Cerutti said:

    > jaysome wrote:


    <snip>

    >> Just make sure to
    >> write a lot of programs and crank up the compiler warning level. For
    >> example, with gcc, this is a good start:
    >>
    >> gcc -Wall -W -ansi -pedantic

    > Why would you use -ansi instead of -c99?


    Most compilers don't conform to C99 (including gcc, despite the switch).

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
    Richard Heathfield, May 10, 2007
    #8
  9. Richard Heathfield wrote:
    > Pietro Cerutti said:
    >
    >> jaysome wrote:

    >
    > <snip>
    >
    >>> Just make sure to
    >>> write a lot of programs and crank up the compiler warning level. For
    >>> example, with gcc, this is a good start:
    >>>
    >>> gcc -Wall -W -ansi -pedantic

    >> Why would you use -ansi instead of -c99?

    >
    > Most compilers don't conform to C99 (including gcc, despite the switch).


    Yes, I know. But still, I don't see the point to completely avoid C99
    features just because some of them are not implemented (yet).
    The "Status of C99 features in GCC" [1] explicitly says what you can use
    safely and what you can't.
    So why not start using the useful features which we have at disposal
    now, and wait for the remaining ones to come, instead of just snobbing
    the whole C99 set of changes?

    [1] http://gcc.gnu.org/c99status.html

    --
    Pietro Cerutti

    PGP Public Key ID:
    http://gahr.ch/pgp
    Pietro Cerutti, May 10, 2007
    #9
  10. Pietro Cerutti said:

    > Richard Heathfield wrote:
    >> Pietro Cerutti said:
    >>
    >>> jaysome wrote:

    >>
    >> <snip>
    >>
    >>>> Just make sure to
    >>>> write a lot of programs and crank up the compiler warning level.
    >>>> For example, with gcc, this is a good start:
    >>>>
    >>>> gcc -Wall -W -ansi -pedantic
    >>> Why would you use -ansi instead of -c99?

    >>
    >> Most compilers don't conform to C99 (including gcc, despite the
    >> switch).

    >
    > Yes, I know. But still, I don't see the point to completely avoid C99
    > features just because some of them are not implemented (yet).


    It depends on your requirements.

    If you are only using one compiler, ever, and don't need your code to
    work with any other compiler, there is no point even in sticking to
    C99. You can use any feature of the implementation that you like!

    But if your code has to work with many implementations (i.e. more than
    one), it may be necessary to restrict yourself to the features that are
    available in all your implementations. And, in some cases, you do not
    know at the time of writing the code which implementation(s) it will
    eventually be required to work with. In such cases, it makes sense to
    write code that conforms to the common subset of C90 and C99.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
    Richard Heathfield, May 10, 2007
    #10
  11. Bill Pursell Guest

    Pietro Cerutti wrote:

    > >>> gcc -Wall -W -ansi -pedantic
    > >> Why would you use -ansi instead of -c99?

    >
    > > Most compilers don't conform to C99 (including gcc, despite the switch).

    >
    > Yes, I know. But still, I don't see the point to completely avoid C99


    A few months back, I had a program that ran approximately 60% slower
    when compiled under gcc with -std=c99 as opposed to -std=c89. I
    didn't spend a lot of time tracking down the issue: I just rewrote
    the (fortunately few) sections of code that were using c99 features.
    Bill Pursell, May 10, 2007
    #11
  12. Default User Guest

    wrote:

    > Hi,
    >
    > I have just finished reading some tutorials on C, I am wondering how I
    > could improve my skill. Is there any advice?


    To improve you must write programs.

    > Is reading others' codes the best way?


    No, not in my opinion. Reading code teaches you the allied skill of
    reading code. It's important for a career as a programmer, but not much
    help in learning to write code. One major reason is that you don't yet
    have the skill level to tell good code from bad.

    My advice is to think of a moderately complex project that interests
    you. Things that you find interesting in and of themselves are more
    pleasurable to work on. And it will be work. It will be slow and
    frustrating in the beginning.

    I used a text-adventure game as my training project. This had a number
    of advantages. First, I was interested in the subject. Secondly, these
    sorts of games cover many aspects of programming, including text
    processing, file management, changeable state, data structures, and
    algorithms galore.

    Most of the tasks were applicable to learning standard C, without
    getting off into platform-specific stuff like graphics.




    Brian
    Default User, May 10, 2007
    #12
  13. Dave Hansen Guest

    On May 9, 9:57 pm, "" <>
    wrote:
    > Hi,
    >
    > I have just finished reading some tutorials on C, I am wondering how I
    > could improve my skill. Is there any advice? Is reading others' codes
    > the best way? If so, what type of codes are suitable for novice? The
    > ones in fsf freed software directory? I have been reading quite a few
    > books on the programming language C, but when I tried to start a
    > project of my own, I find myself to be incompetent. What should I do?
    > Thanks in advance.


    1) Read some _good_ books. K&R, of course, if you haven't already.
    It's fairly old now, but Peter van der Linden's "Expert C Programming:
    Deep C Secrets" is highly readable and contains some good (if somewhat
    Unix-centric) info. It's worth it for the chapter on understanding
    complex declarations all by itself. SAMS C Unleashed also has some
    very good stuff, though it's more specifically directed at solving
    specific problems.

    2) Write more code. The only way to get better at writing C code is
    to practice. The exercises in K&R have been mentioned, and van der
    Linden's book has some good non-trivial exercises in it as well.

    3) Invest in Gimpel's PC-lint, _learn_ how to use it, _run_ all your
    code through it, and _understand_ what it tells you (i.e., fix the
    code, not the error). Awesome tool, and the error descriptions are
    very instructive. www.gimpel.com

    Regards,

    -=Dave
    Dave Hansen, May 10, 2007
    #13
  14. Chris Torek Guest

    In article <4642ea21$0$3815$>
    Pietro Cerutti <> wrote:
    >... I don't see the point to completely avoid C99
    >features just because some of them are not implemented (yet).
    >The "Status of C99 features in GCC" [1] explicitly says what you can use
    >safely and what you can't.
    >So why not start using the useful features which we have at disposal
    >now, and wait for the remaining ones to come ...


    The big problem here is that the set of "C99-isms" that are
    implemented not-at-all, incompletely, or incorrectly varies from
    one compiler to the next (even one gcc to the next, in some
    cases, although actually running into this is much rarer).

    As always, one must make engineering tradeoffs. If some feature
    is sufficiently valuable, you might want to tie yourself to "we'll
    only ever use Zog C version 3.14159265". Just be sure you can
    afford to go down with it if it sinks like the Titanic. :)
    --
    In-Real-Life: Chris Torek, Wind River Systems
    Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
    email: forget about it http://web.torek.net/torek/index.html
    Reading email is like searching for food in the garbage, thanks to spammers.
    Chris Torek, May 11, 2007
    #14
  15. Bill Pursell <> wrote:
    > A few months back, I had a program that ran approximately
    > 60% slower when compiled under gcc with -std=c99 as
    > opposed to -std=c89. I didn't spend a lot of time
    > tracking down the issue: I just rewrote the (fortunately
    > few) sections of code that were using c99 features.


    If it compiled using -std=c89, then what c99 features
    _needed_ rewriting?

    --
    Peter
    Peter Nilsson, May 11, 2007
    #15
  16. jaysome Guest

    On 10 May 2007 15:49:11 -0700, Dave Hansen <> wrote:

    >On May 9, 9:57 pm, "" <>
    >wrote:


    [snip]

    >3) Invest in Gimpel's PC-lint, _learn_ how to use it, _run_ all your
    >code through it, and _understand_ what it tells you (i.e., fix the
    >code, not the error). Awesome tool, and the error descriptions are
    >very instructive. www.gimpel.com


    Excellent advice.

    I've used PC-lint on C and C++ code and have found it invaluable. The
    number of different target platforms/compilers I've used it for is in
    the double-digit range, and I've never come across any
    platforms/compilers where it didn't flag something of concern, and in
    almost all cases flagged one or more plain and simple bugs.

    PC-lint teaches you to become a better programmer, on top of finding
    bugs at compile-time that would hopefully, but not necessarily, be
    found at run-time. Its -w4 option is like a gcc -pedantic option on
    steroids.

    Best regards
    --
    jay
    jaysome, May 11, 2007
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fresh Air Rider

    Is "Whidbey" going to de-skill developers ?

    Fresh Air Rider, Dec 31, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    383
    Peter Blum
    Jan 3, 2005
  2. Roedy Green

    Step Right Up, Test your Skill

    Roedy Green, Jan 27, 2006, in forum: Java
    Replies:
    21
    Views:
    852
    Noodles Jefferson
    Jan 29, 2006
  3. nospam
    Replies:
    169
    Views:
    8,585
    Ingo R. Homann
    Feb 21, 2006
  4. Anand

    Need to Improve my skill set in C

    Anand, Jan 11, 2004, in forum: C Programming
    Replies:
    3
    Views:
    552
    Darrell Grainger
    Jan 11, 2004
  5. Thiago Massa

    Improve ruby skill

    Thiago Massa, Jan 10, 2011, in forum: Ruby
    Replies:
    2
    Views:
    174
Loading...

Share This Page