To expand on lucasgladding's point:
I think programming is more of an art than a science. There's some cases in very controlled situations that there is truly only one way to solve a problem. Otherwise there are normally an infinite number of solutions to any problem, and none of them are "best". Things like the "most elegant" are completely subjective. Things like "fastest" might be objective, but that might not always be the best solution for the particular instance (i.e. if readability and maintainability of the code was completely sacrificed for execution time, in a case that execution time is not an extremely high priority).
Being able to write code that is safe, accurate, and readable is not something you can get from a book. There are books that will help, but it really takes practice, and honing your skills. It also really helps if someone with more experience can look at your code and tell you what they would change, etc. That's where a place like these forums can be helpful, if you don't have immediate access to programmers with many years of experience otherwise.
As an aside, I learned very little about programming in school. When I finished my degree I was an awful programmer. I knew a lot of theory, how things worked, why things worked, and I could certainly write the code needed to complete projects. However, I would be ashamed to put any code I wrote then on a forum like this now. University taught me to think, and think specifically about computer science, but it did not teach me to program.
I am also going to use this opportunity to again espouse the value of learning command line compilation, execution, and debugging before moving to an IDE. I've been spat at and panned for saying you should use vim as your editor, so use any editor you like, but compile using gcc, debug using gdb (if there are other good debuggers, use those, I'm just most familiar w/ gdb), run your program from the command line. Things will be, I think, much clearer as you progress. There is a time and a place for an IDE, but "Hello, World" is not it.
-Lee