Thread: c2040, c2446, and c1075 errors.

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    10

    Angry c2040, c2446, and c1075 errors.

    I recently found a large amount of tutorials to make text based RPG's. I am new at programming but have always wanted to learn and figured this would be a good tool. Anyway, I have ran into my first major problem. I kind of understand what's wrong but I am too inexperienced to fix the problem myself. Please Advise. EDIT: I know I should not place in the whole code as a wall of text isn't what people want to see, the only reason I did is because I am unbelievable new at this and am a little unsure as to what you need to see to be able to help me.

    Code:
    #include "Library.h"
    
    // SUBURBS
    
    void Motel(PLAYER*);
    
    
    bool Suburbs(PLAYER* player)
    {
    	int choice = 0;
    
    
    while(choice != 5);
    	{
    	cout <<"\n\nThe Suburbs\n\nWelcome to the 'Burbs, homie. The suburbs is the place to be for all you need.\nCheck out the PAWN SHOP for all your weapons and accessories, swing by\nthe CLINIC to beat down anything that might be crawlin' (gross), or rest\neasy at the local MOTEL complete with your very own 'massage therapist' in\nevery room\n\n";
    
    	cout <<"Where you headed?\n";
    	cout <<"1:Motel\n";
    	cout <<"2:Clinic\n";
    	cout <<"3:Pawn Shop\n";
    	cout <<"4:Check Stats\n";
    	cout <<"5:Outta Here\n";
    
    	cout <<">";
    
    	cin >> choice;
    
    	cout << endl;
    
    	switch (choice)
    	{
    	case 1:
    		{
    			Motel(player);
    			break;
    		}
    	case 2:
    		{
    			//Clinic();
    			break;
    		}
    	case 3:
    		{
    			//PawnShop();
    			break;
    		}
    	case 4:
    		{
    			//Stats();
    			break;
    		}
    	default: break;
    	}
    
    
    	{
    		return true;
    	}
    
    	void Motel(PLAYER* player);
    	{
    		cout <<"\n\nYou walk into a seedy Motel filled with 'interesting' people. As you make\nyour way to your room, you are greeted by an overly-friendly woman\nholding a riding crop and a pare of sunglasses. Make your move, homie!\n\n";
    
    		char answer[5];
    		answer[0] = 'u';
    
    			while (answer[0] != 'p' || answer != 'l')
    			{
    				cout <<"PAY your dues ($10) or LEAVE quick?";
    				cin >> answer;
    			}
    
    			cout << endl;
    
    			if (answer[0] == 'p')
    			{
    				if (player->GetGold() > 9)
    				{
    					player->SpendGold(10);
    					cout <<"\n\nDamn, you need that! It's amazing how many different uses you can\nfind for a phone cord. (HP and MP fully restored)";
    					player->SetHealth(player->GetMaxHealth());
    					player->SetMana(player->GetMaxMana());
    				}
    				else
    				{
    					cout <<"\n\nLooks like you're outta funds bro!\nCome back when you've got some cash!\n\n";
    					wait();
    					answer[0] = 'n';
    				}
    			}
    
    			if (answer[0] == 'n')
    			{
    				cout <<"\n\nThe Motel is definitely a place to remember to come back to,\nbut you've got stuff to do so let's get on with it!\n\n";
    				wait();
    			}
    	}

    ERRORS: The first 2 errors are on line 67, the last is on the last line but it when I double click to take me to that line, it brings me to the beginning of the document.

    Code:
    Suburbs.cpp(67) : error C2446: '!=' : no conversion from 'int' to 'char *'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    Suburbs.cpp(67) : error C2040: '!=' : 'char [5]' differs in levels of indirection from 'int'
    Suburbs.cpp(98) : fatal error C1075: end of file found before the left brace '{' at 'Suburbs.cpp(14)' was matched
    Last edited by d20junkie; 07-18-2011 at 03:45 PM. Reason: Added more info

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Code:
    while (answer[0] != 'p' || answer != 'l')
    That's the cause of the C2446/C2040 errors I believe.

    The other C1075 error is an indication that you have some mismatched brackets, more of the opening than closing brackets for example.

    You also have a couple extra semicolons that do not belong.

    Code:
    bool Suburbs(PLAYER* player)
    {
        int choice = 0;
    
        while(choice != 5);  <--HERE
        {
    
    
    ...
    
    {  <-- HERE, SHOULD BE } ?
        return true;
    }
    
    ....
    
    void Motel(PLAYER* player);  <--HERE
    {
        cout <<"\n\nYou walk into a seedy Motel filled with 'interesting' people. As you make\nyour way to your room, you are greeted by an overly-friendly woman\nholding a riding crop and a pare of sunglasses. Make your move, homie!\n\n";
    
        char answer[5];
        answer[0] = 'u';
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    While you are at it, you might find it fitting to improve indentation. Makes it easier to spot mismatched braces.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-07-2011, 09:42 AM
  2. Replies: 4
    Last Post: 05-07-2011, 09:42 AM
  3. Replies: 8
    Last Post: 06-04-2009, 02:03 PM
  4. Receiving errors C2446 & C2440.
    By gator6688 in forum C++ Programming
    Replies: 3
    Last Post: 10-05-2007, 02:20 PM
  5. errors.. errrors.. more errors
    By Klinerr1 in forum C++ Programming
    Replies: 17
    Last Post: 07-23-2002, 08:43 PM

Tags for this Thread