Skip to content

Instantly share code, notes, and snippets.

@darkodemic
Created June 4, 2015 14:39
Show Gist options
  • Save darkodemic/84ba90715be564afb73f to your computer and use it in GitHub Desktop.
Save darkodemic/84ba90715be564afb73f to your computer and use it in GitHub Desktop.
Matrice pomocu dinamicke memorije
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//preprocessor
int main(){
int *a[20];
int m,n,i,j;
printf("Vrste m:");
scanf("%d",&m);
printf("Kolone n:");
scanf("%d",&n);
for(int i = 0; i < m; i++){
a[i] = (int *)malloc(n*sizeof(int));
for(j = 0; j < n; j++){
printf("%4.4d ", *(a[i] + j)=100*i +j);
}
printf("\n");
}
for(i = 0; i < m; i++)free(a[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment