I've got some code that defines a variable called 'size' then uses it but for some reason it doesn't work ; the error is "Expression did not evaluate to a constant"
int main()
{
int size;
int userValue;
char input;
do
{
cout << "Enter an int for the size of the array:" << endl;
cin >> size;
int a[size];
cout << "Enter an integer between 1 and " << size << " to search for in the array." << endl;
cin >> userValue;
populateArray(a, size);
linearSearch(a, size, userValue);
binarySearch(a, size, userValue);
cout << "Press 'y' and enter to run again or just enter to quit";
cin.sync();
cin.get(input);
}while(input == 'y');
}
You can ignore the other functions as they are not called before the defining of my array, Ive tried setting size to a value, still doesn't work.
EDIT: forgot to mention
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;