Monday, 12 August 2013

Decrementing a pointer out of bounds; incrementing it into bounds

Decrementing a pointer out of bounds; incrementing it into bounds

Does the following provoke undefined behaviour in line 4 and/or 5:
0 #include <stdio.h>
1 int main(void)
2 {
3 char s[] = "foo";
4 char * p = s - 1;
5 printf("%s\n", p + 1);
6 return 0;
7 }

No comments:

Post a Comment