Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Undefined symbol display(int,int) in noname00.cpp (http://www.go4expert.com/forums/undefined-symbol-display-intint-t29414/)

mistu4u 10Jan2013 19:07

Undefined symbol display(int,int) in noname00.cpp
 
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.

xpi0t0s 11Jan2013 20:47

Re: Undefined symbol display(int,int) in noname00.cpp
 
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.


All times are GMT +5.5. The time now is 21:10.