When I allocate memory in heap via calling malloc my program works(as expected). But when I dont use malloc it doesnt work. So my question is why does it make a difference when I create a struct* in call stack or heap?
struct que{
int data[10];
int front;
int rear;
};
int main(){
//struct que* q;
struct que* q=(struct que*)malloc(sizeof(struct que));;
q->front=-1;
q->rear=-1;
q->data[1]=10;
printf("%d %d",q->rear,q->data[1]);
}