Fixed length().

This commit is contained in:
Murilo Soares Pereira 2010-04-04 00:51:14 -03:00
parent f0aa621e69
commit 84383a3275

View File

@ -19,12 +19,14 @@ bool empty(struct stack *stack) {
}
int length(struct stack *stack) {
struct stack *iterator = stack;
int length = 0;
if (!empty(stack)) {
length = 1;
while (stack->next != NULL) {
while (iterator->next != NULL) {
length++;
iterator = iterator->next;
}
}