Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

One of the most popular questions on stackoverflow.com is this one:

http://stackoverflow.com/questions/4025768/what-do-people-find-difficult-about-c-pointers

Many of the answers seem to gravitate toward the fact that students often don't get a good understanding of what is physically going on when code executes... the very most basic part of this seems to be stack/heap.

I've read through K&R twice and finally have a good understanding of the language, but I don't think that is enough. Nearly every tough question here has the work "stack" or "heap" in the answer, and while I have a limited understanding of what those mean just from context and wikipedia searches, I prefer the comprehensive approach of a textbook. So, please recommend a textbook which explains things like stack, heap, memory allocation, etc from a physical standpoint, as it relates to C programming.

I tried asking this question on stackoverflow and apparently it was not the right place to ask it. So I hope this site is a better location. If not, please consider migrating it to the proper stackexchange site. Thanks.

share|improve this question
    
+1. Really needed knowledge base for many people who venture in C. While concepts of OO is important to better connect higher level problem domain- the lower level concepts actually makes you effective. –  Dipan Mehta Jan 2 '12 at 7:03
add comment

4 Answers 4

up vote 4 down vote accepted

Many of the answers seem to gravitate toward the fact that students often don't get a good understanding of what is physically going on when code executes... the very most basic part of this seems to be stack/heap.

This is indeed true. And one of the most essential need for understanding the machine is even more important when you are in C.

Ref: 1
There is a book to deal with exactly this subject - Write Great Code

There are two volumes of the book - the first one essentially is only about the way in which a typical machine architecture book. Unlike many microprocessor books which focus on particular architecture - here is a book that captures what high level abstractions matter at the time of programming.

The second volume actually tells you about "Thinking Low-Level, Writing High-Level"

Ref: 2
If you want to go even more deep, here is another book - "The art of Assembly language programming"

Unlike most other books - this book introduces Highlevel Assembly language. This is best reference on low level understanding.

Ref: 3
Many issues with C programming revolves around effective usage of memory. These abstractions become key to be able to write scalable systems in C.

Here is a very good resource that focuses on this. http://www.memorymanagement.org/articles/begin.html

Hope this helps.

share|improve this answer
add comment

During my study I used the book "Programming Language Concepts" (Ghezzi, Jazayeri), which has a detailed description of execution models (global variables, stack variables, activation record, heap variables).

share|improve this answer
add comment

The first two chapters of The Art of Exploitation do a pretty good job into describing C programming from a low level point of view: disassembling C code, CPU registers, debugging, pointers and memory, static variables, memory segmentation (including the stack and the heap), and more. Note that the book is using GNU/Linux tools (objdump, gcc, gdb, etc.).

share|improve this answer
add comment

Answering my own question. This may not be the best book for an explicit understanding of C, but it is an excellent book for learning how memory (and all hardware) work with your software. It's helped me immensely. Once I finish it I will tackle some of the other books suggested by the other responders (thanks!).

The Elements of Computing Systems: Building a Modern Computer from First Principles

It's a book/course with the nickname "from NAND to tetris in 12 steps" which teaches you how to build a modern computer with high level applications starting from very basic digital building blocks. Projects in the book include building hardware (gates, adders, ALU, registers, RAM, ROM, CPU, and eventually an entire computer) and then software for it, starting with native machine instructions, then writing an assembler, virtual machine, compiler, OS, and applications. There's really nothing else like it, an entire top to bottom view of a computing system in one digest!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.