Learn C The Hard Way
41–50 of 260 posts
Re: Learn C The Hard Way
#42Re: Learn C The Hard Way
#43Earlier quoted context omitted.
Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.
As a teaching assistant for a class ( http://www.cs.cmu.edu/~410/ ) where students write a whole lot of code in C, please introduce the address-of (&) operator and explain how to obtain pointers without using malloc(). Do this before the concept of the heap is ever introduced at all. Be careful when explaining the compiler and how a program actually runs. I've found that a lot of student problems come from "the compi…
Re: Learn C The Hard Way
#44Earlier quoted context omitted.
> it's not going to rape your family, it'll just crash Well, if it hits undefined behavior it could in fact rape your family, the standard allows for that.
Oh right, I forgot they added that to the C6.283185307179586 standard.
Re: Learn C The Hard Way
#45Re: Learn C The Hard Way
#46I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.
Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.
Re: Learn C The Hard Way
#47Isn't "C For Programmers" essentially "HOWTO Use Pointers"? Is there another really complicated idea that C has which most of its heirs do not have?
Why a string must end with a 0 byte.
Binary shifting numbers, especially signed numbers.
Memory management; it's fun for the whole family, and more than just knowing how to allocate memory and store a pointer to it.
Some other points that I'm sure I'm missing.
Re: Learn C The Hard Way
#48I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.
Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.
Re: Learn C The Hard Way
#49Earlier quoted context omitted.
It's not for the type, but for the output. The 'd' means "decimal" output. For example, you can do %x to "hexadecimal" output, and %o for octal. Of course, there's some complex interplay with what type you hand that function. As for how "dangerous" it is, yeah it's not going to rape your family, it'll just crash. So I'll be showing people how to prevent it.
It'll crash and potentially allow code execution if the rest of the args are user coercible. Check out the first few chapters of The Shellcoder's Handbook for examples. Thanks for the explanation. I've never seen/had to use %d with integers. I've only used it with %.Nd for floats/doubles.
Mentioning code execution and shell code isn't really in the scope. If he mentions code execution, then it sort of warrants mentioning modern architecture prevent executing data as code, or the code segment is not writable on many architectures...and shell code is basically the op code that your machine executes, and injecting shell code in absence of any protecting mechanism will execute arbitrary code, and in presence of protection mechanism, it will crash.
I think just mentioning shell codes and code execution aren't doing a beginner any good. And explaining it is well out of scope. It's not that this is going to be the end all C book, and as long as the reader sticks to using proper format strings, he is good. If he doesn't, knowing about what might happen isn't doing much good either.
Re: Learn C The Hard Way
#50Earlier quoted context omitted.
It's not for the type, but for the output. The 'd' means "decimal" output. For example, you can do %x to "hexadecimal" output, and %o for octal. Of course, there's some complex interplay with what type you hand that function. As for how "dangerous" it is, yeah it's not going to rape your family, it'll just crash. So I'll be showing people how to prevent it.
It'll crash and potentially allow code execution if the rest of the args are user coercible. Check out the first few chapters of The Shellcoder's Handbook for examples. Thanks for the explanation. I've never seen/had to use %d with integers. I've only used it with %.Nd for floats/doubles.
You should probably read this book. :-)