Undefined reference in array
Aug 11, 2014 at 6:55am UTC
I'm getting undefined references error to my printArray function in my main function (printArray (a, MAX)). Any idea's what's wrong? I went over it a similar example I found but I can't seem to find anything. Help appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int MAX = 25;
void genArray (char [], int );
void printArray (char [], int );
int main ()
{
char a [MAX];
srand (time (NULL));
genArray (a, MAX);
printArray (a, MAX);
}
void genArray (char a [], int size)
{
for (int i = 0; i < size; i++)
a [i] = rand () % 52+1;
}
void printArray (const char a [], int size)
{
for (int i = 0; i < size; i++)
cout << a [i] << " " ;
cout << endl;
}
Aug 11, 2014 at 7:02am UTC
The declaration on line 9 does not match the definition.
1 2
// void printArray (char [], int); // line 9
void printArray ( const char [], int ); // modified
Aug 11, 2014 at 7:13am UTC
D'oh. Thank missed me for some reason. Thanks!
Topic archived. No new replies allowed.