Advertisement
drankinatty

C 1D Array as 2D Subarrays by Pointers

Oct 25th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (void) {
  4.    
  5.     int a[] = {1,5,-3},
  6.         *p = a,
  7.         (*pos)[2] = (int(*)[2])p;
  8.    
  9.     printf ("{% d, % d}\n{% d,  x}\n", pos[0][0], pos[0][1], pos[1][0]);
  10.    
  11.     // printf("%d \n",(pos[1][1]));     /* Undefined Behavior */
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement