I am writing a program that will compare stings of data (true false answers) against an answer key which is another string.
for example, the data for the students answers looks like this.
tfttftttf
so question 1 is true question 2 is false etc.
Here is the code I have come up with to compare the "answerkey" to the students answers.
void scoreanswers(scores studentanswers[50], string &answerkey, int &count)
{
for (int i=0;i<count;i++)
{
for (int j=0;j<22;j++)
{
if (answerkey.substr[j]==studentanswers[count].answers[j])
studentanswers[count].grade+=5;
else
if (answerkey.substr[j]!=studentanswers[count].answers[j])
studentanswers[count].grade=-2;
}//end for
}//end for
}//end scoreanswers
the problem is I get this error. Can anyone help me decipher this error
1>g:\c++\scoretest\scoretest\scoretest.cpp(120) : error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::substr': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Ax>::substr' to create a pointer to member
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>g:\c++\scoretest\scoretest\scoretest.cpp(120) : error C2109: subscript requires array or pointer type