Can someone please help me on how to do the conversion of char to int
using either a c-style cast or function-style cast. I have include my code.
#include <iostream>
using namespace std;
int main()
{
char state;
cout << "Please select one of the following state abbreviations:\n";
cout << "\n";
cout << "AL, FL, GA, SC, NC\n";
cin >> state;
if ( state == "AL" || "Al" || "al")
cout << "State selected:\tAL\t\tAlabama\n";
else if ( state == "FL" || "Fl" || "fl")
cout << "State selected:\tFL\t\tFlorida\n";
else if ( state == "GA" || "Ga" || "ga")
cout << "State selected:\tGA\t\tGeorgia\n";
else if (state == "SC" || "Sc" || "sc")
cout << "State selected:\tSC\t\tSouth Carolina\n";
else if (state == "NC" || "Nc" || "nc")
cout << "State selected;\tNC\t\tNorth Carolina\n";
else
cout << "State not listed. Please select one of the listed states\n";
return 0;
}
<< moderator edit: added code tags: [code][/code] >>