0
How we write a program for displaying a character that can be set by any character.
if we type a show:-a=apple that can be set in program
1 Answer
+ 2
Make a dictionary using std::map, and just print the specific element that is a match:
std::map<char,std::string> dict=
{
{'a',"Apple"}, {'b',"Box"}, {'c',"Change"}, {'d',"Drink"}, {'e',"Energy"}
}; //Add more entries yourself
char c; cout<<"Enter Char : ";
cout<<c<<"="<<dict[std::tolower(c)]<<endl;