Advertisement
RicardasSim

example

Dec 26th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main ()
  5. {
  6.  
  7.     int *ptr1, *ptr2;
  8.    
  9.     ptr1=(int *)malloc(32*sizeof(int));
  10.    
  11.     if(ptr1){
  12.        
  13.         for(int i = 0;i<32;i++)
  14.         {
  15.             ptr1[i] = i;
  16.            
  17.         }
  18.        
  19.         ptr2 = &ptr1[5];  
  20.        
  21.         printf("%d\n", *ptr2);
  22.        
  23.         *ptr2 = ptr1[6];
  24.        
  25.         printf("%d\n", *ptr2);
  26.        
  27.         free(ptr1);
  28.     }
  29.    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement