In this part of my program i -obviously- want to create a dynamic array.
But somewhere there is a problem(the array is allocacated but not returned), can anyone help me, is there any problem with the pointers?
I have a warning into the main that A hasn't been initialized
Code:
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int FillStruct(int A[]);
int main(void){
int megethos,*A,epilogi;
srand(time(NULL));
do{
printf("--------------------------\n Main Menu\n--------------------------\n");
printf("Give a choice: ");
scanf("%d",&epilogi);
switch (epilogi) {
case 1:
megethos=FillStruct(A);
break;
.
.
.
.
.
}
return 0;
}
int FillStruct(int A[])
{
int type,zevgaria,thesi,temp,i,megethos;
printf("Please give the length of the struct:");
scanf("%d",&megethos);
A=(int*)calloc(megethos,sizeof(int));
if (A==NULL){
printf("ALLOCATING MEMMORY ERROR");
exit(1);
}
return megethos;
}