this seems like it should be pretty simple, im probably leaving something simple out.
this is the code im trying to run. it is 3 files, 2*cpp and 1*header.
this wont run on code blocks, im trying to see what im missing!
these are the errors given:
obj\Debug\main.o||In function `main':|
|9|undefined reference to `generateArray(int*, int)'|
|11|undefined reference to `reverseOrder(int*, int*, int)'|
|13|undefined reference to `displayArray(int*, int*, int)'|
// lab6.h
#ifndef LAB6_H_INCLUDED
#define LAB6_H_INCLUDED
int const arraySize = 10;
int array1[arraySize];
int array2[arraySize];
void generateArray(int[], int );
void displayArray(int[], int[], int );
void reverseOrder(int [],int [], int);
#endif // LAB6_H_INCLUDED
// lab6.cpp
#include "lab6.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using std::cout; using std::endl;
using std::rand; using std::srand;
using std::time;
using std::setw;
void generateArray(int array1[], int arraySize)
{
srand(time(0));
for (int i=0; i<10; i++)
{
array1[i]=(rand()%10);
}
}
void displayArray(int array1[], int array2[], int arraySize)
{
cout<<endl<<"Array 1"<<endl;
for (int i=0; i<arraySize; i++)
{
cout<<array1[i]<<", ";
}
cout<<endl<<"Array 2"<<endl;
for (int i=0; i<arraySize; i++)
{
cout<<array2[i]<<", ";
}
}
void reverseOrder(int array1[],int array2[], int arraySize)
{
for (int i=0, j=arraySize-1; i<arraySize;j--, i++)
{
array2[j] = array1[i];
}
}
// and finally main.cpp
#include "lab6.h"
int main()
{
generateArray(array1, arraySize);
reverseOrder(array1, array2, arraySize);
displayArray(array1, array2, arraySize);
return 0;
}