Install Valgrind. It makes error messages a lot less cryptic (my #1 problem with C... not that's it's limited to C). If you don't get proper feedback, it's not learning, just banging your head against the wall.
Where to begin when learning C? Start by making lots of errors
51–60 of 90 posts
Re: Where to begin when learning C? Start by making lots of errors
#52Re: Where to begin when learning C? Start by making lots of errors
#53Earlier quoted context omitted.
Nice suggestion. Although I can't seem where one would have to look for those "pretty colours" you mentioned, I certainly can't see any of them on my Mac terminal...
Can't help you there -- but I don't think I've set any exotic terminal variables or anything like that, and I get this: http://i.imgur.com/BjWj7h6.png FWIW, I have: COLORTERM=gnome-terminal TERM=screen and Debian takes care of my termcap etc, afaik.
http://i.imgur.com/0Hzze9G.png
Thats me on osx running tmux with TERM=xterm-256color.
Re: Where to begin when learning C? Start by making lots of errors
#54Where to begin when learning C? Start at http://c.learncodethehardway.org/ . It's going to be tough to top Zed Shaw's approach. The best way to learn code is by writing code.
Re: Where to begin when learning C? Start by making lots of errors
#55By the way, I would love any feedback on this approach and where I should take this further.
As for going further staying with the bare-bones approach, I suppose you'd have to start looking at assembly output and how that fits with what the c-code does. I don't know anything about OSX x86_64 calling conventions etc -- but at least under Linux (and afaik windows) 64bits is a lot more friendly and fun than the mess that was 32bit (and 16bit) x86. There are a couple of great (free) resources on 32bit x86 assemb…
Re: Where to begin when learning C? Start by making lots of errors
#56You should learn go instead of C.
Re: Where to begin when learning C? Start by making lots of errors
#57Earlier quoted context omitted.
People don't like K&R? I can understand it not being suitable for children and the very beginner, but it's one of a very few programming books that is useful, succinct, pragmatic, doesn't get bogged down in APIs, and is written clearly. (The companion book "Programming in the UNIX environment" is the get-you-started guide from the very beginning, although it assumes 1970s terminal defaults)
K&R is the best second C programming book.
Re: Where to begin when learning C? Start by making lots of errors
#58Install Valgrind. It makes error messages a lot less cryptic (my #1 problem with C... not that's it's limited to C). If you don't get proper feedback, it's not learning, just banging your head against the wall.
Re: Where to begin when learning C? Start by making lots of errors
#59Earlier quoted context omitted.
I once had a particularly slow week at work, and decided to write an article about how "Hello World" works in C. How it really works -- including compiling, linking, system calls, operating system involvement, hardware I/O, communication between ICs, etc. The path from the block of text to photons emitting from the screen, with fairly detailed explanations at every level. I ended up with a 50 page LaTeX document that…
I have been looking for a guide like that. I would also appreciate a release of the unfinished version.
https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_fre...
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...
http://timelessname.com/elfbin/
A wee bit heavy, but it's comprehensive. It deals with what happens when you run code, how the architecture of the computer works (by and large) including at the logic level:
http://www.amazon.co.uk/Computer-Systems-Programmers-Randal-...
If you want to go lower (and higher).. look at Understanding the Linux kernel for a good understanding of how an OS is put together, with specific examples i.e. Linux.
Code, by Petzold, deals with logic and computers from the ground up. It starts with relays and builds them up into gates and usable arithmetic blocks.
http://www.amazon.co.uk/Code-Language-Computer-Hardware-Soft...
http://www.amazon.co.uk/Understanding-Linux-Kernel-Daniel-Bo...
The physics is fairly simple, at least from a CRT or LED display perspective. Gets more tricky dealing with interconnecting microprocessors because a good chunk is vendor specific.
I think this kind of project is well suited to a guide on how to build a computer from the ground up, starting with logic gates, writing a real time OS and developing a scripting language that will run and compile on it. Then you can skip a lot of largely extraneous stuff and have a solid understanding of how the hardware works.
Re: Where to begin when learning C? Start by making lots of errors
#60Earlier quoted context omitted.
I am using the default `cc` compiler on Mac OS X for this without any flags, are you saying I should something non-stock in this case?
The Mac OS X C compiler is clang, no need to install anything extra. C is insecure by design and IT is still paying for its widespread, when used by developers that don't use the best practices for secure C coding. So when learning how to use it, the best way is to learn those best practices from day one.
When you're writing the kind of software that's an invitation to hackers, like a web application, you should favor a language like PHP or Ruby, which takes things like buffer overflows out of the equation, and even then, you should know what you're doing.