4 ms·
C works at a very low level. You have lumps of memory, and you can put stuff in it. By convention a "string" is actually a lump of memory with chars in it, an
by RiderOfGiraffes 16y ago
C works at a very low level. You have lumps of memory, and you can put stuff in it. By convention a "string" is actually a lump of memory with chars in it, and the end is indicated by a '\0'. The lump stays the same size and doesn't need tidying.
This is the source of the notorious "fgets" bug/hack/exploit.
This is not the time or place for a tutorial on C strings and memory management, but suffice to say that some people find it horrible, some people find it easy and obvious. It stems from C being a sort of macro-assembler with a simplistic type system glued on top of it.
ADDED IN EDIT: I don't know why you got down-voted - it's a reasonable question from someone who hasn't done C. I've up-voted you to get you back to "1".
- tptacek 16y agofgets() bug/hack/exploit? You mean gets(), right?
- RiderOfGiraffes 16y agoEr, probably. Brain fried, too much multi-tasking. Sorry.