Hello all, I am stuck once again. I created an array with a size of 12 and what I have to do is let the user pick an index and the index they pick removes it from the array. I need to output the final array elements, array size and the array element that was removed.
I haven't gotten to the delete part even though I can't find how to delete an index from an array in the chapter so was going to ask the professor on Monday(unless one of you know how to). Here is what I have so far but giving me 3 errors which I don't see why I am getting them.
ERRORS:
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2059: syntax error : '{'
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2143: syntax error : missing ';' before '{'
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2143: syntax error : missing ';' before '}'
Why am I getting these? I have the ; where they are needed to be, at least I think so...
I haven't gotten to the delete part even though I can't find how to delete an index from an array in the chapter so was going to ask the professor on Monday(unless one of you know how to). Here is what I have so far but giving me 3 errors which I don't see why I am getting them.
Code:
#include <iostream>
#include <iomanip>
using namespace std;
void removeAt(int [], int, int);
int main() {
const int len = 1;
int ylist[len];
int index = 1;
removeAt(ylist, len, index);
return 0;
}
void removeAt(int ylist[], int len, int index)
{
len = 12;
ylist[len] = {4, 23, 65, 34, 82, 37, 12, 17, 24, 36, 82, 51};
cout << "Please pick an array index from 0 to " << (len - 1) << ": ";
cin >> index;
for (int loc = 0; loc < len; loc++)
if (ylist[loc] == ylist[index])
{
cout << "The array element that you are removing is " << ylist[loc] << endl;
}
}
ERRORS:
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2059: syntax error : '{'
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2143: syntax error : missing ';' before '{'
1>c:\users\welcome back\documents\visual studio 2008\projects\searchandremove\searchandremove\search.cpp(25) : error C2143: syntax error : missing ';' before '}'
Why am I getting these? I have the ; where they are needed to be, at least I think so...