I'm pretty new to C++ and wanted to create a text based RPG.
But i have never learned how to store text like inventory = "banana". and i can only seem to as an if for a full word not two seperate ones. I hope i can get some help. i've set in some examples in my messy code. hope it's readable/understandable
/*
Body of room 1
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include "headerRpg.h"
usingnamespace std;
//variables
char userInput[50];
string inventory; // is it possible to acces inventry from another file example: cout << roomOne::inventory;
roomOne::roomOne()
{
cout << "" << endl;
//main loop
while (true)
{
cout << "\nYou are in a dark room with a big wooden door blocking your way.\n>> ";
cin >> userInput;
cin.ignore();
if (!strcmp(userInput, "quit"))
{
system("cls");
cout << "Quitting" << endl;
cin.ignore();
break;
}
if (!strcmp(userInput, "search" /* and "search room"*/))
{
system("cls");
cout << "As you search through the room, you come across a small dark box laying on the floor." << endl;
cin.ignore();
continue;
}
elseif (!strcmp(userInput, "search box"))// <---- two words wont work?
{
system("cls");
cout << "As you search through the box, and find an old metal key.\n";
cout << "Key acquired" << endl;
inventory = "key"; // <-- add key to inventory?
cin.ignore();
system("cls");
continue;
}
}
}
i appreciate all the help and tips i can get.
again sorry for the bad syntax and messy program.