I shall make an example:
My project is on command line, and its checking for commands all the time, and i got commands like: Display.All.Ages, and it display ages of a class called bots. But i would like to make like: Display.Ages.1 and it only display the age of the Bot number 1.
Here's how im detecting commands:
First i store them into chars
Code: Select all
///Commands
char Command_Hello[256] = "hello";
char Command_Stop[256] = "stop";
char Command_Clear[256] = "cls";
char Command_ShowAge[256] = "display.ages";
char Command_ShowGender[256] = "display.genders";
Code: Select all
cin >> Command; //check for command
if(strcmp(Command, Command_Hello) == 0)
{
cout << "Hello to you sir" << endl;
Blank();
}
else if(strcmp(Command, Command_Stop) == 0)
{
cout << "Bye Bye" << endl;
Blank();
Running = false;
}
else if(strcmp(Command, Command_Clear) == 0)
{
system("cls");
Blank();
}
else if(strcmp(Command, Command_ShowAge) == 0)
{
for(int i = 0; i < 30; i ++)
{
cout << "Bot #" << i << " Age: " << bot.age[i] << " years" << endl;
}
Blank();
}
else if(strcmp(Command, Command_ShowGender) == 0)
{
for(int i = 0; i < 31; i ++)
{
if(bot.gender[i] == 0) cout << "Bot #" << i << " Gender: Female" << endl;
if(bot.gender[i] == 1) cout << "Bot #" << i << " Gender: Male" << endl;
}
Blank();
}
I dont know how to this.. If you guys know tell me please