'}' error..expected unqualified-id before 'else'

I'm getting three errors: 1) "expected '}' before 'else' 2)expected unqualified-id before 'else' and 3)expected declaration before '}' token
(I'll mark where the errors appear and thank you very much... sorry about the copy/paste formatting)

int newin()
{
int pos_input = 1;
struct list *newone, *p;

newone = (struct list *) malloc (sizeof (struct list));
while(pos_input)
{
printf("\nEnter a new number : ");
scanf("%d", &(newone->next));
if(newone->next > 0)
{
if(base == (struct list *) NULL)
{
newone->next = base;
base = newone;
}
else
{
p = base;
if(p != NULL && newone->x >= p->x);
{
newone->next = base;
base = newone;
}

else // 1) HERE
{
while(p->next != NULL && p->next->x >= newone->x)
p = p->next;
newone->next = newone;
}
}
newone = (struct list *) malloc (sizeof (struct list));
}
else // 2) HERE
pos_input = 0;
} // 3) HERE
}
Place your code in code tags and use correct indentation!
Use code tags, it makes it much easier to read your code:

[code]put your code in these tags[/code]


One problem I see is here:

 
if(p != NULL && newone->x >= p->x); // <- this shouldn't have a semicolon 


Also, newin has a return type of int, but you never return anything. Should this return void instead?
Oh wow thanks, I looked for a long time and never saw that.. that's what it was.
Topic archived. No new replies allowed.