Please help me fix this syntax C++ error

Deleted.
Last edited on
What line is the error on?
On line 36 you call to the lower function before it's declaration.
if (lower(word[j]) > lower(word[j+1]))


Same problem on line 37 with the swap function.
swap(word[j], word[j+1]);


Also the lower function expects a string[] but you pass it a string.
Last edited on
What is your syntax error? Copy and past it here. Also where does the user input the names. If I'm not mistaken, your trying to pass "name" to "GetNames" in the main, which you haven't done anything. Try something like:
1
2
3
4
5
6
7
int main()
{
       string name[MAX_NAMES]; //if you're using a for loop then use it in the main.
      cin >> name;
//then add the rest and pass "name" to the functions.
//also your "int i" isn't being used anywhere in the main.
}

Last edited on
This might help...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Compiling...
XXXX-c018.cpp
C:\Documents and Settings\two\Desktop\Classworks\XXXX-c018.cpp(36) : error C2065: 'lower' : undeclared identifier
C:\Documents and Settings\two\Desktop\Classworks\XXXX-c018.cpp(42) : error C2373: 'lower' : redefinition; different type modifiers
C:\Documents and Settings\two\Desktop\Classworks\XXXX-c018.cpp(44) : error C2228: left of '.length' must have class/struct/union type
C:\Documents and Settings\two\Desktop\Classworks\XXXX-c018.cpp(45) : error C2664: 'tolower' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'int'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Documents and Settings\two\Desktop\Classworks\XXXX-c018.cpp(46) : error C2664: '__thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::std::basic_string<char,struct std::char_traits<char>,class s
td::allocator<char> >(const class std::allocator<char> &)' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > []' to 'const class std::allocator<char> &'
        Reason: cannot convert from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > []' to 'const class std::allocator<char>'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

Classworks.exe - 5 error(s), 0 warning(s)

Last edited on
its tolower //not lower um in your header try adding #include <cctype> and cut and paste const int MAX_NAMES = 10; to your main.
Last edited on
Topic archived. No new replies allowed.