Hey there i'm creating a linked list and I'm stuck here.
please look at the code below and explain what the problem is.
it tells me on
Code:
if (loc > (length()+1) || loc <= 0)
"implicit declaration of function length is invalid in C99"
plz help
here's the code
Code:
void add_at(char info[100], int loc)
{
int i;
struct Node *temp, *prev_ptr, *cur_ptr;
cur_ptr = Head;
if (loc > (length()+1) || loc <= 0)
{
printf("\n Insertion at given location is invalid\n");
}
else
{
if (loc == 1) // If the location is starting of the list
{
insert_beg(&info[100]);
}
else
{
for (i=1; i<loc; i++)
{
prev_ptr = cur_ptr;
cur_ptr = cur_ptr->next;
}
temp = (struct Node *)malloc(sizeof(struct Node));
temp->data = info[100];
prev_ptr->next = temp;
temp->next = cur_ptr;
}
}
}
hope i'm clear on this post.
please let me know
thanks