 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
weidongtom@gmail.com Guest
|
Posted: Thu May 10, 2007 7:57 am Post subject: How to improve C skill? |
|
|
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. |
|
| Back to top |
|
 |
Malcolm McLean Guest
|
Posted: Thu May 10, 2007 9:11 am Post subject: Re: How to improve C skill? |
|
|
<weidongtom (AT) gmail (DOT) com> wrote in message
news:1178765822.870170.46160 (AT) o5g2000hsb (DOT) googlegroups.com...
| Quote: | 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 |
|
| Back to top |
|
 |
Laurent Deniau Guest
|
Posted: Thu May 10, 2007 9:11 am Post subject: Re: How to improve C skill? |
|
|
jaysome wrote:
| Quote: | On 9 May 2007 19:57:02 -0700, "weidongtom (AT) gmail (DOT) com"
weidongtom (AT) gmail (DOT) com> 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. |
|
| Back to top |
|
 |
jaysome Guest
|
Posted: Thu May 10, 2007 9:11 am Post subject: Re: How to improve C skill? |
|
|
On 9 May 2007 19:57:02 -0700, "weidongtom (AT) gmail (DOT) com"
<weidongtom (AT) gmail (DOT) com> wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
Richard Heathfield Guest
|
Posted: Thu May 10, 2007 9:11 am Post subject: Re: How to improve C skill? |
|
|
weidongtom (AT) gmail (DOT) com said:
| Quote: | 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?"
| Quote: | 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.
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. |
|
| Back to top |
|
 |
Ian Collins Guest
|
Posted: Thu May 10, 2007 9:11 am Post subject: Re: How to improve C skill? |
|
|
weidongtom (AT) gmail (DOT) com wrote:
| Quote: | Hi,
I have just finished reading some tutorials on C, I am wondering how I
could improve my skill. Is there any advice?
|
Plenty!
| Quote: | 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.
| Quote: | 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. |
|
| Back to top |
|
 |
Peter Nilsson Guest
|
Posted: Fri May 11, 2007 7:39 am Post subject: Re: How to improve C skill? |
|
|
Bill Pursell <bill.purs...@gmail.com> wrote:
| Quote: | 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 |
|
| Back to top |
|
 |
jaysome Guest
|
Posted: Fri May 11, 2007 9:12 am Post subject: Re: How to improve C skill? |
|
|
On 10 May 2007 15:49:11 -0700, Dave Hansen <iddw (AT) hotmail (DOT) com> wrote:
| Quote: | On May 9, 9:57 pm, "weidong...@gmail.com" <weidong...@gmail.com
wrote:
|
[snip]
| Quote: | 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 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|