3 ms·
C's biggest mistake. But in other news most don't know that a[3] == 3[a]
by glouwbug 4mo ago
C's biggest mistake.
But in other news most don't know that a[3] == 3[a]
- throwaway27448 4mo agoEven more irrelevant than the array type
- parlortricks 4mo agoI didn't understand why a[3] == 3[a], but i found this stackoverflow that explains it. https://stackoverflow.com/a/16163840 https://stackoverflow.com/a/16163840 In C a[i] is converted to *(a+i) internally. i[a] is converted to *(i+a). Array names also act as pointers in c. so (a+i) or (i+a) give an address (using pointer arithmetic) that is dereferenced using
- parlortricks 4mo agoIn C a[i] is converted to *(a+i) internally. i[a] is converted to *(i+a). Array names also act as pointers in c. so (a+i) or (i+a) give an address (using pointer arithmetic) that is dereferenced using *
- glouwbug 4mo agohttps://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistake.html