i'm working on an assignment to make a vector emulator and i'm having problem solving 2 of my functions the last 2 or ( insert and printing ) ..
so i was hoping someone could help me with that ?
string* addEntry(string *dynamicArray, int &size, string newEntry)
{
string *newArray = new string[size + 1];
string *newArray = new string[size - 1];
for(int ix = 0; ix < size; ++ix)
{
//copy all except entryToDelete (hér þarf að laga)
newArray[ix] = dynamicArray[ix];
}
--size;
return newArray;
}
int findEntry(string *dynamicArray, int size, string entry)
{
// Finds the first occurrence of an entry in the dynamic array, returning the position (int)
size_t found;
found=entry.find("Aron");
if (found!=string::npos)
{ cout << "the string you entered can be found" << int(found) << endl;
return 0;
}
else return -1;
// where found. If not found, then returns -1
}
string* insertEntry(string *dynamicArray, int &size, string newEntry, int pos);
// Inserts an entry into position pos in the dynamic array, returning a pointer to the
// expanded array. size should contain the size of the array. It
// will be updated when the array is expanded
void print(string *dynamicArray, int size);