char array[8] = "Raining";
I think that all the comments below that are consistent with the statements are true to my understanding.
char *p1 = array + 7; --> points to '\0' char *p2 = array + 8; --> undefined behaviour char *p3 = array + 9; --> undefined behaviour char *p4 = array + 10; --> undefined behaviour
Do I understand correctly?
In your case
char *p1 = array + 7;
and
char *p2 = array + 8;
valid because you are allowed to point to
Oto
char *p3 = array + 9;
char *p4 = array + 10;
are undefined.
Quote C11, chapter §6.5.6, “Additive operators” (emphasis)
C11
[ C99, §6.5.6/p8, - ]
C99
, , , result . , , . , P i - , (P)+N (, N+(P)) (P)-N ( N N) i+n -th i−n -th , . , P , (P)+1 , Q , (Q)-1 . , ; undefined. [...]
P
i
(P)+N
N+(P)
(P)-N
N
i+n
i−n
(P)+1
Q
(Q)-1
array 8 - NULL-.
array
char *p1 = array + 7; .
char *p2 = array + 8; . . ( .)
: undefined. .
, . .
char *p1 = array + 7; \\-->points to '\0', within array char *p2 = array + 8; \\-->defined behaviour until dereferenced
, , , , , (*d++ = *s++);.
*d++ = *s++);
, ( ) ( ) : [beginning,end).
[beginning,end)
Source: https://habr.com/ru/post/1655038/More articles:Build an application using more confusing code? - androidPolymer 1: Prohibit attaching iron / application pages to all pages at loading - performancePython Pandas - how 25 percentiles are calculated using the description function - pythonPaypal Rest Api With RestSharp does not work in xamarin android - c #What is a jcc instruction in x86 - assemblyAndroid Studio: Mesa software renderer is deprecated. Use Swiftshader for software - androidRedirecting and Restoring STDERR in Dancer - perlKafka consumer for multiple threads - javaOwn service - no services registered for type - c #Usermanager.DbContext is already hosted by middleware - asp.netAll Articles