1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Undefined symbol display(int,int) in noname00.cpp

Discussion in 'C' started by mistu4u, Jan 10, 2013.

  1. mistu4u

    mistu4u New Member

    Joined:
    Oct 19, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Following is my code.
    Code:
    //Array passing to Function
    #include<stdio.h>
    #include<stdlib.h>
    void display(int ,int);
    void main()
    {
        int i,ar[10],n;
        printf("\n Enter the no of no's->");
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            printf("\n Enter no->");
            scanf("%d",&ar[i]);
        }
        display(ar[10],n);
    }
    void display(int ar[10],int n)
    {
        int i;
      for(i=0;i<n;i++)
        {
            printf("\n Enter no->%d",ar[i]);
        }
        }
    
    It is compiling fine. But when I am pressing Ctrl-F9 to run it, I am getting this error.

    Undefined symbol display(int,int) in noname00.cpp

    where my file name is "noname00.cpp". I have tried with other file names, but no success. Please help me finding the error. Thanks.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    The problem is not the filename. The problem is that you have prototyped display(int,int) but not defined it. That is why you are getting a missing symbol. The solution is either to define display(int,int), or more likely it's the prototype itself that's wrong and should be defined as void display (int ar[10],int n);

    Another solution which removes the need for a prototype is to define display() above main(). Prototypes are really only needed (a) in header files for functions you wish to make public, or (b) where two functions call each other.
     

Share This Page