-
Best way to pick up C?
I've been doing C programming as one of my subjects last semester for my day release at Uni. Working full time and doing keeping up with uni work is tough, but I have managed it thus far. However, I'm still having SERIOUS problems with C programming. I passed my exam, but my assignment was worthless because I couldn't explain my code to my lecturer. In fairness, although I kinda understand the code, I can't explain it because it's been knocked up and chopped and changed until it worked, with the help of colleagues.
I don't find C interesting, simple, but I need to grasp it if I am to do my assignment legitimatly and pass the unit. Maybe even if I begin to understand it more I might enjoy doing it.
Right now I have a spare hour at work, but just looking at my code sends a shiver down my spine. :mad:
Is there any techniques/tips/advice anyone has to take C by the scruff of the neck and hammer it in to submission?
-
-
The best way to learn is from your mistakes. The most valuable
thing a begginer can do is to obtain reliable demonstration code
(like the tutorials on this site) and spend a fair amout of time
playing with said code in order to fully grasp the concept of what
is being demonstrated. Although you say you understand the
code, the best way to be able to explain it is to also understand
how you have applied the features of C to the task.
A good example of this is if you were asked to write a function
that performs a certain task, and you are asked to write the code
to successfully complete the task as efficiently as possible. for
that you might consider a significant amout of variable reuse,
perhaps using pointers, maybe even cut corners on unlikely
cases (not recommended but sometimes people do it). To explain
that, you would need to know why you are using those features.
Other strongly recommended tips would be to write functions
to modularize your program, USE EFFECTIVE INDENTATION and
also a text editor/IDE configured to highlight matching braces,
keywords etc. definitely use logical variable names too,
foo, bar and baz should only ever be used in a pseudocode
demonstration! Hope that gives you a few ideas
-
well honestly the best advice I can give you is to practise! seriously! it's the only way to learn things (especially programming!)!
if you have time, I'd say try out some of the things you learn in the lectures etc. try to modify what was discussed to do slightly different things, see if you can make it better! but seriously, the only way to learn is to practise!
-
I will strongly echo what the previous posters have said.
If you're learning to speak Italian, when you first start, everything sounds like gibberish. As you pick up and begin to understand some words and some grammar, more of it makes sense. The more you practice and immerse yourself in it, the more familiar it becomes.
Pick up the aforementioned K&R (The C Programming Language by Brian Kernighan & Dennis Ritchie). It starts simple and works its way along.
When you have code examples from class, if you see something you don't understand, attack it -- pick it apart. Ask questions -- of your professor, of your peers and here in this forum.
Over time, you'll begin to understand more and more....