#include <stdio.h>
#include <stdlib.h>
void dim(int*,int);
int main()
{
int *array ;
int n,i;
scanf("%d",&n);
dim(array,n);
for(i=0;i<n;i++)
scanf("%d",&array[i]);
for(i=0;i<n;i++)
printf("%2d",array[i]);
}
void dim(int *array,int n){
array=malloc(n* sizeof(int));
}
why this don't work? i can't do this?
I can't give a dimension to an array through a function?
I tried to find on Internet how this works, but i dint find anything so i prefer to post it here for a direct answer.
Thanks! and sorry for my English.