First of all, I'd advise you to describe what your problem is *exactly*. Otherwise no one is willing to help you.
But because I have a good day today, I'll just tell you this: you delete always the letter number five, but you
need to delete letters at the position you calculated.
IMPORTANT EDIT: You calculate the string size when checking the loop condition. And since you delete chars from
the string, it gets shorter and shorter, so the loop runs only 4 times.
Fix this by doing it like this:
#include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(){
string inputWord("MYSTERE");
string shuffledWord;
int size(inputWord.size());
for (int i=0 ; i < size; i++){
int position(0) ;
srand(time(0));
position = rand() % inputWord.size();
shuffledWord += inputWord[position];
inputWord.erase(position, 1);
}
cout << "shuffled word : " << shuffledWord<<endl;
return 0;
}
I changed the <= in the loop condition to a <, otherwise your loop will run 1 times too often, since indexing starts at 0.
Try to see all changes and understand why they were necessary.