dynamic memory allocation example in c

https‮//:‬www.lautturi.com
dynamic memory allocation example in c
/*
Example:Dynamic Memory allocation in C language
*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>

int main() {
   int row = 3, col = 5;
   int *arr = (int *)malloc(row * col * sizeof(int));
   int i, j;
   for (i = 0; i < row; i++)
      for (j = 0; j < col; j++)
         *(arr + i*col + j) = i + j;
   printf("print:\n");
   for (i = 0; i < row; i++) {
      for (j = 0; j < col; j++) {
         printf("%d ", *(arr + i*col + j));
      }
      printf("\n");
   }
   free(arr);
   return 0;
}

output:

print:
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6

Process returned 0 (0x0)   execution time : 0.156 s
Created Time:2017-08-28 15:52:40  Author:lautturi