It looks like a demonstration of arrays as pointers in conjunction with a demonstration of pointer arithmetic. The version that works is a convoluted way of assigning the reference (address) of chr to ptr.
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393
Seg faults are caused when your program accesses (and potentially corrupts) portions of your system's memory that are not assigned to it. Odds are address 1000 is not an address assigned to your program.
Thus, for the first version of your program, that is not an unexpected result.
Fbody
Posting Maven
2,930 posts since Oct 2009
Reputation Points: 833
Solved Threads: 393