Skip to content

Instantly share code, notes, and snippets.

@k0f1sh
Created September 8, 2015 11:08
Show Gist options
  • Save k0f1sh/0ad4812bd1d89d8e0597 to your computer and use it in GitHub Desktop.
Save k0f1sh/0ad4812bd1d89d8e0597 to your computer and use it in GitHub Desktop.
ポインタに+1した時の挙動
#include <stdio.h>
int main()
{
int a = 0;
int *ptr = &a;
printf("intsize = %d\n", sizeof(int));
printf("base = %p\n", ptr);
printf("base + 1(int) = %p\n", ptr + 1);
printf("base + 1(char) = %p\n", (char *)ptr + 1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment