It stops while giving input in vs code.... while it works on online c compiler, onlinegdb. What should I do so it works in vs code too, all the settings in vs code also seem to be fine but somehow this code is not working
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
int exp;
struct node *next;
};
int main()
{
int n,i=0;
struct node *head,*newnode,*temp;
head=0;
printf("Enter number of elements:");
scanf("%d",&n);
while(i<n)
{
newnode= (struct node*)(malloc(sizeof(newnode)));
printf("Enter data:");
scanf("%d",&newnode->data);
printf("Enter Power:");
scanf("%d",&newnode->exp);
newnode -> next=0;
if(head==0)
{
head=temp=newnode;
}
else
{
temp->next=newnode;
temp=newnode;
}
temp->next=head;
i++;
}
struct node *temp1;
if(head==0)
{
printf("Empty list");
}
else
{
temp1=head;
while(temp1->next !=head)
{
printf("%d(x)^%d",temp1->data,temp1->exp);
temp1=temp1->next;
if((temp1->data)<0)
{
printf(" ");
}
else
{
printf(" + ");
}
}
printf("%d(x)^%d",temp1->data,temp1->exp);
}
}