subscript-operator

Do pointers support “array style indexing”?

喜夏-厌秋 提交于 2019-11-27 03:40:56
问题 (Self-answered Q&A - this matter keeps popping up) I assume that the reader is aware of how pointer arithmetic works. int arr[3] = {1,2,3}; int* ptr = arr; ... *(ptr + i) = value; Teachers/C books keep telling me I shouldn't use *(ptr + i) like in the above example, because "pointers support array style indexing" and I should be using ptr[i] = value; instead. No argument there - much easier to read. But looking through the C standard, I find nothing called "array style indexing". In fact, the