Reputation: 39
I have doubly linked list and Ive made a function to check whether the list is empty or not.
Function code:
int isEmpty(list *l)
{
if(l->head== NULL && l->tail== NULL)
return 1;
else
return 0;
}
List
typedef struct list
{
struct element *head;
struct element *tail;
}list1;
and Im trying to use this function but there is nothing when i open console
case 11:
printf("List is : %d\n", isEmpty(&list1));
break;
Upvotes: 0
Views: 2036
Reputation: 46
You passing wrong parameter to the function. you should pass paramater to isEmpty() such as isEmpty(struct list* l) or isEmpty(list1* l)
int isEmpty(struct list *l)
{
if(l->head== NULL && l->tail== NULL)
return 1;
else
return 0;
}
call the function as
isEmpty(list1)
it gives correct result.
Upvotes: 0
Reputation: 1625
list1
is a type so: printf("List is : %d\n", isEmpty(&list1));
is meaningless,
Try:
list1 l1;
.
.
.
case 11:
printf("List is : %d\n", isEmpty(&l1));
break;
Upvotes: 1
Reputation: 39
It was working but this messsage was disappearing after some milliseconds. I added system("pause");
and its working now.
Upvotes: 0