hey guys it was my first time using void as parameter my code fails hardly though i dunno whats the problem in failing
i m srry had problem in return code
Code:
#include <stdio.h>
#include <stdlib.h>
#define array_num 100
int allocating_memory_func(void *stuff,int num,int num2)
{
stuff=malloc(num2 * num);
if(stuff==NULL)
return 0;//func failed
return 1;//function is cool
}
int main(void)
{
int x;
int *y;
if(!allocating_memory_func(y,array_num,sizeof x)){
free(y);
puts("Function failed");
getchar();
exit(0);}
else{
for(x=0;x<array_num;x++){
fputs("Please enter your num: ",stdout);
scanf("%d",x[y]);}
for(x=0;x<array_num;x++){
printf("num %d is in array %d",x,x[y]);
}
}
getchar();
return getchar();
}