SE250:lab-2:kkan048

From Marks Wiki
Revision as of 05:18, 3 November 2008 by Mark (Sọ̀rọ̀ | contribs) (6 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#include <stdio.h>

int main(void)
{
 int* int_p;
 void* void_p;
 float* float_p;
 double* double_p;
 char* char_p;

 printf("Size of pointer int %d void %d float %d double %d char %d\n",
        sizeof(int_p),sizeof(void_p),sizeof(float_p),sizeof(double_p),sizeof(char_p));

     return 0;

}

There are 5 fundamental data types :

Integer 
  int  
Character 
char 
Floating Point 
float 
Double precision floating point
double 
Void 
void

http://www.exforsys.com/tutorials/c-language/c-programming-language-data-types.html

IN Window Size of pointers int 4 void 4 float 4 double 4 char 4

In Linix Size of pointers int 4 void 4 float 4 double 4 char 4

There are no difference bewteen the size of pointers of the data types. And the size of pointers are same in Win & Linix

int x;
int y;
printf("pointer_x = %p,pointer_y = %p,(long)(&x-&y)=%ld\n",&x,&y,(long)(&x-&y));
printf("(long)&x-(long)&y=%ld\n",(long)&x-(long)&y);

In linix

pointer_x = 0x22ccb0,pointer_y = 0x22ccac,(long)(&x-&y)=1
(long)&x-(long)&y=4

In window

pointer_x = 0xfff1a9d8,pointer_y = 0xfff1a9d4,(long)(&x-&y)=1
(long)&x-(long)&y=4