I'm having a fascination in C language right now and I'm trying to crack the pointers mistery. I have expirience in Python, Ruby, but this things feel strange to me. I've stumbled upon this article:
https://www.geeksforgeeks.org/applications-of-pointers-in-c-cpp/
I do understand the basic concept of it but when it comes to real life implementation I'm a bit puzzled. I do understand dynamic memory allocation with the usage of a pointer, also passing arguments by reference from the link (swap example), but when it comes to accessing arrays I have a question - What is the point of a pointer here actually if arr[2]
and *(arr + 2)
are the same thing ? Is there a performance benefit ? or is it only a different way to write it ?