Arrays and strings

Hey guys, I'm trying to pass a string into a string into a public member function and I can't get it to work.

From main:

string Array;
cout << "Enter all of tghe answers without spaces: ";
cin >> Array;
Test.setKey(Array);


From class function:

void TestGrader::setKey(string ANS)
{
for(int i = 0; i < 20; i++
{
answer[i] = ANS[i];
}
}


Any help would be much appreciated!
Last edited on
What do you expect this to do, and what is actually happening? (If you just want to copy the string, you can just do answer=string if answer is a std::string).
Last edited on
I'm trying to pass elements of a string into an array
What do you want to happen, and what is happening? It's a bit hard to understand if you write that little.
Topic archived. No new replies allowed.