Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
ArjunKumar
Gerbil In Training
Topic Author
Posts: 6
Joined: Fri May 31, 2019 3:47 am

How do I get better in C programming?

Fri May 31, 2019 3:54 am

Hello All, Can anyone tell me how do I get better in C Programming?
 
NTMBK
Gerbil XP
Posts: 371
Joined: Sat Dec 21, 2013 11:21 am

Re: How do I get better in C programming?

Fri May 31, 2019 4:04 am

The same way you get to Carnegie Hall- practice!

Get yourself a good IDE, with integrated code highlighting and a built in debugger. Visual Studio is absolutely fantastic, though technically only supports C++ and not C. Then start writing some code and building things. Make mistakes! Learn from those mistakes! Look at a lot of codebases, play around with them.
 
Usacomp2k3
Gerbil God
Posts: 23043
Joined: Thu Apr 01, 2004 4:53 pm
Location: Orlando, FL
Contact:

Re: How do I get better in C programming?

Fri May 31, 2019 6:37 am

Welcome to TR!
The best thing for me personally is start with a problem in mind that you'd like to solve with code. Make it a simple problem at first and then maybe move on to progressively harder problems. Practicing something that has a tangible, real-world beneficial outcome is very fulfilling.
 
notfred
Maximum Gerbil
Posts: 4610
Joined: Tue Aug 10, 2004 10:10 am
Location: Ottawa, Canada

Re: How do I get better in C programming?

Fri May 31, 2019 8:55 am

Also look at code from other people. After you've spent some time in the trenches fixing other people's bugs, you get to appreciate what's a good way of coding and what's a bad way.

You could take a look at an Open Source project and look through their bug reports. Try and find something that's a really simple one liner that may be being skipped over by others on the team because they are busy fixing the bigger issues. Submit a patch in (very humbly!) and see if it is accepted. Even if it isn't you may learn something about how to code.
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: How do I get better in C programming?

Fri May 31, 2019 9:28 am

Usacomp2k3 wrote:
Welcome to TR!
The best thing for me personally is start with a problem in mind that you'd like to solve with code. Make it a simple problem at first and then maybe move on to progressively harder problems. Practicing something that has a tangible, real-world beneficial outcome is very fulfilling.

This.

And "real-world beneficial" doesn't have to mean "useful"; it can mean "fun". Back in the day, I learned a lot about programming by writing simple games. More recently (but still quite a few years ago...), I taught myself Python by writing a Mandelbrot/Julia fractal exploration application.
Nostalgia isn't what it used to be.
 
dragontamer5788
Gerbil Elite
Posts: 715
Joined: Mon May 06, 2013 8:39 am

Re: How do I get better in C programming?

Fri May 31, 2019 11:45 am

As others have said: practice. You'll want to write "complete" programs as much as possible.

As a beginner, you'll probably have difficulty with just 10 lines of code. But write a bunch of toy problems, and soon you'd be writing 100 lines of code to solve bigger problems. Write a toy program to play "rock-paper-scissors". Write a program to solve the quadratic equation. Write FizzBuzz. A bunch of small stuff.

Grow to ~1000 lines of code, which starts to look like real projects. TicTacToe solver, Checkers. Even a raytracer can be written in under 1000 lines of code. Maybe a small GUI that helps you play some game or analyze Baseball statistics or something. When you're confident in your skills, try a larger project, something that will take 10,000 lines of code to finish.

To practice 100,000+ lines of code, instead to change something in some open source code that you use a lot. Write a Linux kernel module. Write a plugin to some open source game. Fix that bug in Blender and/or Gimp that's been driving you nuts.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On