DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4

Thread: C++ MUD help

  1. #1
    Join Date
    Jan 2007
    Posts
    18

    C++ MUD help

    Hey, im making a very basic MUD and developing a movement system prototype.
    When a player moves into a different room the "location" integer is changed and depending on that number, the while statement will switch to that room. I only made one while statement and im already getting error messages. Please help.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char n, s, w, e;
        char command;
        int location = 1;
        while(location == 1){
                 cout<<"Obvious Exits: East, West, North, South\nThis is a large damp room\nThere is a steel flaming sword on the ground\n";
                 cin>>command;
                 if (command == e) {location = 2);
                 else if (command == w) {location = 3};
                 else if (command == n) {location = 4};
                 else if (command == s) (location = 5};
                 else {cout<<"That is not a command\n";
                 
        
    }   
       
       
       
        return EXIT_SUCCESS;
    }

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    What's the question exactly?
    Danny Kalev

  3. #3
    Join Date
    Jan 2007
    Posts
    18
    When I run it I get abunch of error messages

    C:\Dev-Cpp\Basic.cpp In function `int main(int, char**)':
    15 C:\Dev-Cpp\Basic.cpp expected `;' before ')' token
    16 C:\Dev-Cpp\Basic.cpp expected primary-expression before "else"
    16 C:\Dev-Cpp\Basic.cpp expected `;' before "else"
    17 C:\Dev-Cpp\Basic.cpp expected primary-expression before "else"
    17 C:\Dev-Cpp\Basic.cpp expected `;' before "else"
    18 C:\Dev-Cpp\Basic.cpp expected primary-expression before "else"

    C:\Dev-Cpp\Makefile.win [Build Error] [Basic.o] Error 1
    27 C:\Dev-Cpp\Basic.cpp expected `}' at end of input
    And so on

  4. #4
    Join Date
    Dec 2003
    Posts
    3,366
    your braces are out of order. best I can tell, with the non aligned braces, you have while { if{ }end while } end program with the if bracer never paired up.

    Personally, I always type open and close of anything as a pair right away and then go back between them so they never misalign.

Similar Threads

  1. Help with MUD
    By theillbehaviore in forum C++
    Replies: 4
    Last Post: 02-16-2007, 12:05 AM
  2. Docs clear as mud
    By Barry in forum .NET
    Replies: 2
    Last Post: 04-21-2002, 12:47 PM
  3. WMI - Clear as mud
    By Joe Shields in forum VB Classic
    Replies: 0
    Last Post: 06-05-2001, 04:08 PM
  4. WMI - Clear as mud
    By Joe Shields in forum VB Classic
    Replies: 0
    Last Post: 06-05-2001, 04:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links