Skip to content

Instantly share code, notes, and snippets.

@sinannar
Created December 25, 2011 19:21
Show Gist options
  • Save sinannar/1519636 to your computer and use it in GitHub Desktop.
Save sinannar/1519636 to your computer and use it in GitHub Desktop.
about pointers memory
#include<iostream>
using std::cout;
using std::endl;
int main(void)
{
int a[10];
cout<<"a="<<a<<" a+1="<<(a+1)<<" a+2="<<(a+2)<<" a+3="<<(a+3)<<endl<<endl;
cout<<sizeof(int)<<endl;
void * b;
b=a;
cout<<"int icin "<<a<<" "<<b<<" "<<b+sizeof(int)<<" =>fark= "<<sizeof(int)<<endl;
cout<<"long int icin "<<a<<" "<<b<<" "<<b+sizeof(long int)<<" =>fark= "<<sizeof(long int)<<endl;
cout<<"double icin "<<a<<" "<<b<<" "<<b+sizeof(double)<<" =>fark= "<<sizeof(double)<<endl;
cout<<"long double icin "<<a<<" "<<b<<" "<<b+sizeof(long double)<<" =>fark= "<<sizeof(long double)<<endl;
cout<<"float icin "<<a<<" "<<b<<" "<<b+sizeof(float)<<" =>fark= "<<sizeof(float)<<endl;
cout<<"short icin "<<a<<" "<<b<<" "<<b+sizeof(short)<<" =>fark= "<<sizeof(short)<<endl;
cout<<"long icin "<<a<<" "<<b<<" "<<b+sizeof(long)<<" =>fark= "<<sizeof(long)<<endl;
cout<<"long long icin "<<a<<" "<<b<<" "<<b+sizeof(long long)<<" =>fark= "<<sizeof(long long)<<endl;
// cout<<"short short icin "<<a<<" "<<b<<" "<<b+sizeof(short short)<<" =>fark= "<<sizeof(short short)<<endl; bunda hata verıyo
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment