我不是很擅长编程,也没有经验,这对于老师帮助微不足道的班级来说是微不足道的。
标题是我得到的错误。这是功能:
void CapFormat (string Names, int NameCount)
{
int Comma;
int c;
int d;
string::size_type len;
for(c = 0; c < NameCount; c ++)
{
len = static_cast<unsigned> (Names[c].size); //error starts here
for(d = len; d > 0; d --)
{
tolower((Names[c].at(d))); //supposed to lower cases every letter
}
touppper(Names[c].at(0)); //supposed to upper case first letter
Comma = Names[c].find(","); //supposed to find a comma between last and first names
Comma = Comma + 1;
toupper(Names[c].at(Comma)); //Error here as well. supposed to then upper case letter after the comma.
}
}
这是错误的扩展版本:
In function âvoid CapFormat(std::string, int)â:
error: request for member âsizeâ in âNames.std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((long unsigned int)c))â, which is of non-class type âcharâ
error: request for member âatâ in âNames.std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((long unsigned int)c))â, which is of non-class type âcharâ
error: request for member âatâ in âNames.std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = error: âtouppperâ was not declared in this scope
error: request for member âfindâ in âNames.std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((long unsigned int)c))â, which is of non-class type âcharâ
error: request for member âatâ in âNames.std::basic_string<_CharT, _Traits, _Alloc>::operator[] [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((long unsigned int)c))â, which is of non-class type âcharâ
Cstring、cctype 和 string 都包括在内。我直接从我的书中复制了语法,一切都应该井井有条,但错误仍然存在。
协助将不胜感激。