Your IP : 216.73.216.40


Current Path : /var/www/html/bibhas.ghoshal/ITP_2019/lab/
Upload File :
Current File : /var/www/html/bibhas.ghoshal/ITP_2019/lab/pointer_attributes.c

//
//  pointer_attributes.c
//  
//
//  Created by Bibhas Ghoshal on 20/02/21.
//

#include <stdio.h>
int main()
{
    int i =97; char c ="A"; short s = 97;
    int *p_int = &i;    char *p_char = &c;  short *p_short =&s;
    
    // Size of poinetr cmpared to size of dereferenced object
    
    printf("Size of: p_char = %d, *p_char = %d\n", sizeof p_char, sizeof *p_char);
    printf("Size of: p_short =%d, *p_short = %d\n", sizeof p_short, sizeof *p_short);
    printf("Size of: p_int =  %d, *p_int = %d\n", sizeof p_int, sizeof *p_int);
           
    // Adding 1 to the pointer
           
    printf("Size of: p_char = %p, p_char +1 = %p\n",  p_char,p_char+1);
    printf("Size of: p_short =%p, p_short+1 = %p\n", p_short,p_short+1);
    printf("Size of: p_int =  %p, p_int+1 = %p\n", p_int, p_int+1);
                  
    // Dereferencing a null pointer
           
           p_short = NULL;
           printf("Dereferenced value of null poinetr = %hd\n",*p_short);
    
    return 0;
  }