Witam próbuje dynamicznie zaalokować pamięć na wskaźnik w strukturze . Jednak mój program sie zawiesza nie do końca wiem dlaczego.
#include <stdio.h>
#include <stdlib.h>
struct bufor
{
int *abc;
int begin;
int end;
int size;
unsigned char full:1;
};
int create(struct bufor *wsk, int size)
{
if(wsk==NULL || size<=0) return 1;
wsk->abc=(int *)malloc(sizeof(int*)*size);
if(wsk->abc==NULL) return 2;
wsk->begin=0;
wsk->end=0;
wsk->size=size;
wsk->full=0;
return 0;
}
int main()
{
struct bufor *wsk;
int size,wybor,x;
printf("Podaj wielkosc bufora : ");
scanf("%d",&size);
x=create(wsk,size);
if(x==1)
{
printf("Error");
return 1;
}else if(x==2)
{
printf("Failed to allocate memory");
}
return 0;
}