moveToBeginning: Put the value that was elimiated into the first position of the array

int moveToBeginning(string a[], int n, int pos);

Eliminate the value at position pos by copying all elements before it one place to the right. Put the value that was thus eliminated into the first position of the array. Return the original position of the item that was moved to the beginning. Here's an example:

string people[5] = { "juliet", "sierra", "samuel", "echo", "november" };
int s = moveToBeginning(people, 5, 2); // returns 2
// people now…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store