What does this quote about char pointers mean?

后端 未结 4 1700
长情又很酷
长情又很酷 2021-01-24 06:24

I\'ve read a paragraph but I can\'t understand what does it mean....can anyone please explain? the paragraph is :

processing a single character as a cha

4条回答
  •  有刺的猬
    2021-01-24 07:19

    I'm a little worried about the source of that paragraph -- it feels pretty ancient.

    Every modern operating system provides protected memory. Every process gets its own address space, and the physical machine's low memory is not accessible to programs without performing some pretty significant operations (such as iopl(2) or ioperm(2) on Linux systems).

    The low memory is not mapped into processes because it is the easiest way to catch attempts to write to the NULL pointer (which is essentially the address 0x0) and char variables (rather than char * variables). The OS could perfectly well map the page at virtual address 0x0 to any page of memory it wants. (Mapping the zero-page is sometimes required for compatibility mode execution of ancient or arcane systems.)

    Of course, if you're reading a guide on programming machines without MMUs, then it makes some sense, but I'd still be wary.

提交回复
热议问题