2 commands seperated by a freespace?:P
what I cant make work is having a commandline which can take 2 commands seperated by a space.. like "get potion" or "wear shirt".. its probebly as easy as anything but cant make my code work.. if anyone have a few tips about what Im doing wrong it would be lovely:P here is my code as it is now:
Code:
#include <iostream.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
char first[10], second[10];
int wear()
{
if (second == "shirt") {cout << "\nYou wear the ragget old shirt";}
if (second == "pants") {cout << "\nYou wear the pants";}
if (second == "caps") {cout << "\nYou wear the red caps";}
if (second == "boots") {cout << "\nYou wear the smooth, black boots";}
else {cout << "\nYou dont have that to wear!";}
return (0);
}
int get()
{
if (second == "shirt") {cout << "\nYou get a ragget old shirt";}
if (second == "pants") {cout << "\nYou get tha pants";}
if (second == "caps") {cout << "\nYou get the red caps";}
if (second == "boots") {cout << "\nYou get a pair of smooth, black boots.";}
else {cout << "\nYou cant see that item anywhere";}
return (0);
}
int main(void)
{
while(1)
{
cout << "\nYour command? ";
cin >> first >> second;
if (first == wear) {wear();}
else if (first == get) {get();}
else if (first == exit) {exit(1);}
else {cout << "\n What? Who? When!?";}
}
}
I would be gratefull for any hints:P