Skip to content

Instantly share code, notes, and snippets.

@fatih
Created June 4, 2012 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatih/2870790 to your computer and use it in GitHub Desktop.
Save fatih/2870790 to your computer and use it in GitHub Desktop.
An example of 3[my_array] == my_array[3] in C
#include <stdio.h>
int main(void)
{
int my_array[] = {13, 4, 9, -5, 45};
printf("This is my_array[3]: %d\n", my_array[3]);
printf("This is 3[my_array]: %d\n", 3[my_array]);
return 0;
}
@baybatu
Copy link

baybatu commented Jun 5, 2012

Çok enteresan hakikaten. Dillerdeki söz dizimler birbirine çok benzese de semantikleri arasındaki büyük farklara güzel bir örnek.

*(my_array + 3) ile *(3+my_array) in aynı olmasından dolayı bu kullanım sıkıntı yaratmıyor. Bu bilgi de burada kalsın. Belki işe yarar :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment