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
char*string can lead to a fatal
runtime error. a char* string is a
pointer probably a large integer.
however a character is a small
integer(ascii 0-255). on many systems,
dereferencing a char vaalue causes an
error, because low memory addresses
are reserved for special purposes such
as operating system interrupt
handlers- so “memory violations”
occur.
It means you shouldn’t do something like:
because there is a vast difference between a character and a character pointer.
In fact, a decent compiler should give you a warning when you attempt to do something like that.
The rest of it explains one possible effect. If you’re working in a system where
charvalues are eight bits, they will only be able to hold values from 0 through 255 inclusive (the ISO C standard allows char values to be larger but it’s fairly uncommon). It’s very unlikely that a pointer chosen at random from that value set will be useful.It’s not totally out of the question since you may be on an embedded system where you have memory-mapped I/O down there but, in that case, you’d be more likely to use something like
#define IOPORT7 0x0041and useIOPORT7rather than'A'.Pointers, on the other hand, tend to be able to point at your entire address space, which can be 32 bits wide (or larger). 32 bits gives you about four billion possible values where a pointer can point to.