SHARE
TWEET

2D-array access of raw data

Archon Aug 15th, 2012 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef char Matrix[10][10];
  5.  
  6. int main(){
  7.    Matrix *p;
  8.    char *data = malloc(100);
  9.    int i, j;
  10.  
  11.    for (i = 1; i <= 100; ++i)
  12.       data[i-1] = (char)i;
  13.  
  14.    p = data;
  15.  
  16.    for (i = 0; i < 10; ++i){
  17.       for (j = 0; j < 10; ++j)
  18.          printf("%4d", (*p)[i][j]);
  19.       printf("\n");
  20.    }
  21.  
  22.    free(data);
  23.    return 0;
  24. }
RAW Paste Data
Top