Do you not have a compiler handy? Your code doesn't even compile.
Your idea of displaying characters is also incorrect, you can't just concatenate the words into one string.
Since 5 words were mentioned, you're probably expected to use an array of words, e.g.:
Code
std::array<string,5> words;
Then you need to store 5 integers into a similar array and then simply display them correctly.
Here's a way over the top implementation:
Code
#include <array>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <utility>
using namespace std;
int main()
{
array<string,5> words;
array<int,5> integers;
cout << "Enter words: " << endl;
copy_n(istream_iterator<string>(cin), 5, begin(words));
cout << "Enter secret integers: " << endl;
copy_n(istream_iterator<int>(cin), 5, begin(integers));
transform(begin(words), end(words), begin(integers),
ostream_iterator<char>(cout),
[](string const& s, int n){
return s[n];
});
}
http://melpon.org/wandbox/permlink/9zCv5NZ8hnBeEiy2This post was edited by KrzaQ2 on Sep 16 2014 12:54pm