I want a chunk of code that will start will an array of 6 numbers.
Prompt the user to enter one of the 6 numbers.
Check to see if that number is one of the options.
if it is --> assign that value to a variable and delete it from the array
else --> prompt the user again.
Repeat until all numbers have been used.
Verify then end result with a print out.
Here is what I have so far:
int searchList(int[], int, int); // In the header
// In the body
int x[] = {1,2,3,4,5,6};
int search, value;
cout << " What is the value you would like to use? ";
cin >> search;
value = searchList(x, 6, search);
delete x[value];
Try to compile and get an error saying that the delete command is looking for a pointer...
Tried this:
int searchList(int[], int, int); // In the header
// In the body
int x[] = {1,2,3,4,5,6};
int search, value;
int* ptr = x[value];
cout << " What is the value you would like to use? ";
cin >> search;
value = searchList(x, 6, search);
delete ptr;
Received an error: invalid conversion int to int...
Okay... Tried this:
int searchList(int[], int, int); // In the header
// In the body
int x[] = {1,2,3,4,5,6};
int search, value;
int* ptr = &x[value];
cout << " What is the value you would like to use? ";
cin >> search;
value = searchList(x, 6, search);
delete ptr;
I get a long list of "[Linker error] undefined reference to `searchList(int*, int, int)' " on compile.
Need a little guidance, am I trying to do something that is that is not allowed or is there another command I should be using?
Thanks for your help in advance!


Sign In
Create Account


Back to top









