array

[Error] ld returned 1 exit status
.cpp:(.text+0x21): undefined reference to `fill_array(int*, int, int&)'

is this because I forgot ;?

[my code]

#include<iostream>
using namespace std;

int const DECLARED_SIZE=20;

void fill_array (int [], int size, int& number_used);

int search (const int a[], int number_used, int target);
int main()
{
int arr[DECLARED_SIZE], list_size, target;
fill_array(arr, DECLARED_SIZE, list_size);
char ans;
int result;
do
{
cout<<"Enter the number information: ";
cin>>target;

result=search(arr, list_size, target);
if(result==-1)
cout<<target<<" number entered is not in the list of information. \n";
else
cout<<target<<" is stored in an array file position "
<<result<<endl
<<"(Remember: The first postion number starts with 0.) \n";

cout<<"Please review the entered number information (self-learning followed by return): \n";
cin>>ans;
}while ((ans == 'n') && (ans == 'N'));

cout<<" End of the program. \n";
return 0;
}
void fill_array(int a[], int size, int number_used)
{

cout<<" Enter numbers up to: "<<size<<" non-negative numbers. \n"
<<" Mark the end of the list with negative numbers \n";

int next, index=0;
cin>>next;

while ((next >=0) &&(index<size))
{
a[index]=next;
index++;
cin>>next;
}
number_used=index;
}
int search (const int a[], int number_used, int target)

{
int index=0;
bool found=false;
while ((!found) &&(index< number_used))
if (target==a[index])
found=true;

else
index++;

if(found)
return index;
else
return -1;
}
Line 6: Your forward declaration says you're passing the third argument by reference.

Line 35: number_used is passed by value.

These are two different signatures. They must agree.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
These are not the same.
1
2
void fill_array (int [], int size, int& number_used);
void fill_array(int a[], int size, int number_used)
thank you so much for the reply!
Topic archived. No new replies allowed.