Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 16th, 2008, 3:31 PM   #1
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 97
Rep Power: 0 commodore is an unknown quantity at this point
Newb interactive fiction

I'm trying to learn C++ and I started coding an interactive fiction game for practice and I can't get this to compile:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
 
void handle_input(std::string input)
{
    if (input=="quit")
    {
        std::cout<<"Goodbye";
        std::exit(0);
    }
 
    else if (input=="look"){std::cout<<currentRoom.description;}
 
    else {std::cout<<"I don't understand what you're saying\n";}
}
 
class Room
{
    public:
        std::string description;
        std::vector<Room> exits;
};
 
int main()
{
    Room firstRoom;
    firstRoom.description="Description of first room";
    Room currentRoom=firstRoom;
 
    std::cout<<"Hi"<<"\n";
    std::string input;
 
    while (true)
    {
        std::cout<<">>> ";
        std::cin>>input;
        handle_input(input);
    }
    return 0;
}
What am I doing wrong and what am I doing bad?
commodore is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RE working in the Interactive but not in script nytrokiss Python 11 Nov 20th, 2006 8:37 PM
C++ programming newb INeedAGig1210 C++ 2 May 28th, 2006 11:47 AM
newb needs help with classes and char arrays AbalahDoon C++ 13 Jul 2nd, 2005 11:01 AM
Interactive of program? jesslee Visual Basic .NET 0 Jun 18th, 2005 2:29 AM
Newb here Komodo C++ 16 Jun 2nd, 2005 1:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC