Skip to content

Instantly share code, notes, and snippets.

@takaswie
Created February 25, 2017 02:50
Show Gist options
  • Save takaswie/bcbc87bbf44580a0c8c3c412cc608de9 to your computer and use it in GitHub Desktop.
Save takaswie/bcbc87bbf44580a0c8c3c412cc608de9 to your computer and use it in GitHub Desktop.
Address and indirection operators
#include <stdio.h>
#include <stdlib.h>
struct hoge {
unsigned int number;
char data[512];
unsigned int hoge;
};
int main(void)
{
struct hoge h;
char *d;
h.data[0] = 12;
printf("%p\n", h.data);
printf("%p\n", &h.data);
d = &h.data;
printf("%d\n", h.data[0]);
printf("%d\n", d[0]);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment