You're making that up.
If two unrelated objects can be determined to be contiguous
Then you have established a relation between them so they aren't
unrelated.
and if only the higher addressed object has a null byte,
then there are no words in the standard
which exempt a standard library string output function, like puts,
from working with an argument that points to the lower addressed object.
The rules of pointer arithmetic in normal code do not allow access of
array elements beyond the array size. As such a string as C defines it
MUST have a null character within the original array object. If you
violate this requirement when calling a standard library function that
stipulatesa pointer to a string then you invoke undefined behaviour.
If puts can't incremenent a pointer through the string without invoking
undefined behavior, then it's up to puts to find another way.
No, you have violated puts()'s call requirements by not passing it a valid
string.
/* BEGIN new.c */
#include <stdio.h>
#define HELLO "Hello "
int main(void)
{
char hello[sizeof HELLO - 1] = HELLO; char world[] = "world";
if (world == hello + sizeof hello) {
Consider that even though the 2 pointer values ``world'' and
``hello + sizeof hello'' may compare equal they need not be the same
pointers. For example they may contain segment/boundary information which
is not used in the comparison. It simply may not be possible to access any
data in world from a pointer to hello (e.g. the system would trap from
such an access). This might make it clearer why a pointer to a character
in hello is not a valid pointer to a string, even at this point in the
code.
puts(hello);
/* puts("wow"); */
} else {
puts("Hello world");
}
return 0;
}
}
/* END new.c */
Lawrence