Implicit declaration HELP PLZ

This is a discussion on Implicit declaration HELP PLZ within the C Programming forums, part of the General Programming Boards category; Hey there i'm creating a linked list and I'm stuck here. please look at the code below and explain what ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    108

    Implicit declaration HELP PLZ

    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

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,306
    So you have this:
    Code:
    length()
    That is a function call. The name of the function being called is length. That function is either declared later in that file, or it's declared in another file, and you need to #include the right header (.h) file, or it's not declared at all. C reads top-down and doesn't know about some function it hasn't seen yet, so it complains complains. When you call that function in add_at, the compiler knows nothing about it. What is it's return type? What kind of parameters does it take, or does it not take params? Without that info, the compiler can't tell you if you're using the function correctly, thus the error/warning.
    Last edited by anduril462; 02-12-2013 at 04:04 PM. Reason: fix wording

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    108
    true my bad i\m an idiot i completely forgot about that!
    wow not much sleep

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Implicit declaration
    By JFonseka in forum C Programming
    Replies: 4
    Last Post: 11-27-2007, 06:35 AM
  2. implicit declaration
    By bazzano in forum C Programming
    Replies: 8
    Last Post: 10-29-2005, 10:37 PM
  3. implicit declaration
    By siubo in forum C Programming
    Replies: 5
    Last Post: 05-08-2003, 01:56 AM
  4. implicit declaration
    By laasunde in forum C Programming
    Replies: 1
    Last Post: 11-19-2002, 09:18 AM
  5. What does implicit declaration mean?
    By Gamma in forum C++ Programming
    Replies: 1
    Last Post: 04-17-2002, 11:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21