#include <stdio.h>
#include <stdlib.h>
void beolvas(int *a,int n,constchar * file)
{
int i;
FILE * fin;
fin = fopen("be.txt", "rt");
fscanf(fin,"%i",&n);
a = (int*)malloc(n*sizeof(int));
for(i = 0; i < n; ++i){
fscanf(fin,"%i",&a[i]);
}
free(a);
}
void kiir(int *a,int n)
{
int i;
for(i = 0; i < n; ++i){
printf("%i ",a[i]);
}
}
The problem is that I get memory garbage everytime and the file contains five numbers which must be read and write to monitor.If I write the void kiir is code to void beolvas function it works well.
Thanks,redbull1996
Tha t is one thing what I forgot but I still get memory garbage.For example in the file I have the number 12 then I get a long number xD I really don't know the problem.