What does this error mean?

This is a discussion on What does this error mean? within the C++ Programming forums, part of the General Programming Boards category; I am getting these errors when I try to compile, can someone help --------------------Configuration: Cpp1 - Win32 Debug-------------------- Compiling... Cpp1.cpp ...

  1. #1
    ryancsutton
    Guest

    What does this error mean?

    I am getting these errors when I try to compile, can someone help

    --------------------Configuration: Cpp1 - Win32 Debug--------------------
    Compiling...
    Cpp1.cpp
    F:\Cpp1.cpp(29) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
    F:\Cpp1.cpp(46) : error C2181: illegal else without matching if
    F:\Cpp1.cpp(50) : error C2181: illegal else without matching if
    F:\Cpp1.cpp(54) : error C2181: illegal else without matching if
    F:\Cpp1.cpp(58) : error C2181: illegal else without matching if
    F:\Cpp1.cpp(62) : error C2181: illegal else without matching if
    F:\Cpp1.cpp(74) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.

    Cpp1.obj - 7 error(s), 0 warning(s)


    and here is the code:

    #include <iostream>
    #include <string>

    using namespace std;

    int main()
    {
    int dum = 0;
    char bleh;
    string input;
    string str2 = "ABC", str3 = "DEF", str4 = "GHI",
    str5 = "JKL";
    string str6 = "MNO", str7 = "PQRS", str8 = "TUV",
    str9 = "WXYZ";


    cout << "Please enter a Seven letter word, all uppercase ";
    getline(cin, input);

    if (input.length() !=7)
    {
    cout << "The word you typed in is not seven characters in length";
    return 1;
    }


    while (dum <= 6)
    {
    bleh = input.substr(0,1);

    if (str2.find(bleh) != string::npos)
    {
    cout << "2";

    }
    else if (str3.find(bleh) != string::npos)
    {
    cout << "3";

    }

    else if (str4.find(bleh) != string::npos)
    {
    cout << "4";

    else if (str5.find(bleh) != string::npos)
    {
    cout << "5";

    else if (str6.find(bleh) != string::npos)
    {
    cout << "6";

    else if (str7.find(bleh) != string::npos)
    {
    cout << "7";

    else if (str8.find(bleh) != string::npos)
    {
    cout << "8";

    else if (str9.find(bleh) != string::npos)
    {
    cout << "9";


    dum++;



    }
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    70

    use code tags

    I may not be able to help, but i help others help =/

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    int dum = 0;
    char bleh;
    string input;
    string str2 = "ABC", str3 = "DEF", str4 = "GHI",
    str5 = "JKL";
    string str6 = "MNO", str7 = "PQRS", str8 = "TUV",
    str9 = "WXYZ";
    
    
    cout << "Please enter a Seven letter word, all uppercase ";
    getline(cin, input);
    
    if (input.length() !=7)
    {
    cout << "The word you typed in is not seven characters in length";
    return 1;
    }
    
    
    while (dum <= 6)
    {
    bleh = input.substr(0,1);
    
    if (str2.find(bleh) != string::npos)
    {
    cout << "2";
    
    }
    else if (str3.find(bleh) != string::npos)
    {
    cout << "3";
    
    }
    
    else if (str4.find(bleh) != string::npos)
    {
    cout << "4";
    
    else if (str5.find(bleh) != string::npos)
    {
    cout << "5";
    
    else if (str6.find(bleh) != string::npos)
    {
    cout << "6";
    
    else if (str7.find(bleh) != string::npos)
    {
    cout << "7";
    
    else if (str8.find(bleh) != string::npos)
    {
    cout << "8";
    
    else if (str9.find(bleh) != string::npos)
    {
    cout << "9";
    
    
    dum++;
    
    
    
    }
    return 0;
    }

  3. #3
    ryancsutton
    Guest

    nevermind

    ok saw that I was missing a bunch of }

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You have a lot of unwanted {'s after your else's.

    >bleh = input.substr(0,1);
    substr returns a string, as therefore cannot be assigned to a char (which is what bleh is).

    Please use code tags next time. (See my signature).
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    70
    well yea i can, you forgot to end your if statements..

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    int dum = 0;
    char bleh;
    string input;
    string str2 = "ABC", str3 = "DEF", str4 = "GHI",
    str5 = "JKL";
    string str6 = "MNO", str7 = "PQRS", str8 = "TUV",
    str9 = "WXYZ";
    
    
    cout << "Please enter a Seven letter word, all uppercase ";
    getline(cin, input);
    
    if (input.length() !=7)
    {
    cout << "The word you typed in is not seven characters in length";
    return 1;
    }
    
    
    while (dum <= 6)
    {
    bleh = input.substr(0,1);
    
    if (str2.find(bleh) != string::npos)
    {
    cout << "2";
    
    }
    else if (str3.find(bleh) != string::npos)
    {
    cout << "3";
    
    }
    
    else if (str4.find(bleh) != string::npos)
    {
    cout << "4";
    }
    
    else if (str5.find(bleh) != string::npos)
    {
    cout << "5";
    }
    
    else if (str6.find(bleh) != string::npos)
    {
    cout << "6";
    }
    
    else if (str7.find(bleh) != string::npos)
    {
    cout << "7";
    }
    
    else if (str8.find(bleh) != string::npos)
    {
    cout << "8";
    }
    
    else if (str9.find(bleh) != string::npos)
    {
    cout << "9";
    }
    
    
    dum++;
    
    
    
    }
    return 0;
    }

  6. #6
    Registered User IanelarAzure's Avatar
    Join Date
    Sep 2002
    Posts
    7
    Another problem...your header:

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;

    Should be:

    Code:
    #include <iostream>
    #include <string.h>
    
    using namespace std;

  7. #7
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    Code:
    code:--------------------------------------------------------------------------------
    
    #include <iostream>
    #include <string.h>
    
    using namespace std;
    
    --------------------------------------------------------------------------------
    Why are you saying <string.h> is correct if you are using a namespace std notation??????? and the string class the <string> is correct else if he is using c-strings use <cstring>

    Mr. C

  8. #8
    Registered User IanelarAzure's Avatar
    Join Date
    Sep 2002
    Posts
    7
    My apologies, but I have a similar program and I used namespace std; and <string.h>. Was just trying to help.

    Sorry, but please dont jump down my throat about it. :\

  9. #9
    Registered User
    Join Date
    Aug 2002
    Posts
    67
    I sense a mood swing

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21