How we write a program for displaying a character that can be set by any character. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

1st Sep 2018, 2:07 AM
Ankit Kumar
Ankit Kumar - avatar
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;
1st Sep 2018, 3:34 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar