M: you know the COBOL MOVE statement?
H:Yup.
M: So when I say 'MOVE "hello world" INTO greet' what is happening?
H: The sequence of characters gets moved into the variable greet.
M: Nearly right. The characters get copied - MOVE should really be called COPY. And where do you think those characters get copied from?
H: I don't know.
M: Well, they are copied from one area of memory to another. When your compiled program is run, things like "hello world" are loaded along with the actual executable code, and given an address in memory.
[at this point i drew a diagram, but cannot be arsed doing so now]
H: OK so far
M: So when we do the COPY of "hello world" we need to have some memory to copy it into. Now, in COBOL the compiler takes care of generating code to do this, but (for a variety of reasons) the C compiler does not. So we have to do it ourselves using functions like malloc. Anyway, don't worry - you've been doing well on the course so far, and we can go through this again tomorrow, if you would like.