I'm quite sure of your skill level, purpose for learning and age but here's my best advice:
1) Write your code knowing someone else will read it. This means using comments to explain what you want your code to do so they can understand your though process. Even if no one else reads it, if you need to come back to it and if you've forgotten, your comments will save you. Write your code like an english paper. A little known secret is that english majors actually make the best coders. They understand the importance of formatting, style and readability. Understanding code is more important that just getting it to work.
2) Don't code without a plan or design. Use flowcharts and block diagrams before you start coding. Write a document that describes what you plan on doing. Write pseudo code in your .c or .cpp files to provide an outline of sorts. This will keep your code on track and prevent your code/functions from doing too much.
3) Write modular code. Modular code is efficient, small and easy to implement. It also helps you follow your design by abstracting/separating features and functions.
4) Know your target. For a PC, memory is abundant and CPU power is 'infinite'. You should still be aware of memory leaks (malloc/free, new/delete) but it's not completely critical. For an embedded system, ie, Atmel, MSP430, etc. you REALLY need to pay attention to your array sizes, heap, etc.
5) Learn from the masters. Anyone who codes well in C knows about K&R (
http://en.wikipedia.org/wiki/The_C_P...Language_(book)) Buy it. Seriously. Anyone who codes well in C++ knows about the gang of four (
http://en.wikipedia.org/wiki/Gang_of_Four_(software)) and Scott Meyers' Effective C++. Again, seriously. Buy these books. If you're trying to become a professional SW engineer, try to get a job at a telecom company. They are known for their coding prowess, process, standards, etc. Remember C and C++ were both created by engineers at Bell Labs (now Lucent/Alcatel). Personally, I'd stay away from learning from open-source code, ie, Linux and they underlying frameworks. Community projects typically don't have people that are as invested as you'll find at private organizations. Also, if you're thinking about the embedded route, Jack Ganssle always has helpful tips. Or you can contact me as well :)
6) Constant learning. Formal education helps, but writing code on your own is the best teacher. Also read coding magazines such as Dr. Dobbs Journal. A little bit about myself: I have a degree in Electrical Engineering but my SW experience started 20 yrs ago when I learned BASIC, Forth, Pascal, then C. I work professionally, predominantly in C and C++, but have dabbled in Java, C#, html and so on. I subscribe to many industry journals, attend seminars and webinars and trade shows to stay fresh.
Personally, I believe C and C++ are the best languages to learn. C#, ruby, python, VB (ugh) and the scores of scripting languages and object-oriented languages may not last 10-15 years from now, but C and C++ will. They are the closest to human readable microcode you can get and virtually every single intelligent electronic device was developed in C. They have matured well and there are plenty of frameworks out there that keep them viable.
Good luck on your journeys!!