Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const char states[50][25] = { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware",
"Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" };
const char abb[50][3] = { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" };
char alphabet[54]={"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
cout << "Select a state: " << endl;
for ( int count = 0; count < 51; count++ ) { // count represents corresponding state numbers
if ( count != 0 ) { // eliminates the zero in the array
cout << setw( 10 ) << count << setw( 20 ) << states[count - 1]; // counts and ties states to 1 - 50
if ( count % 2 == 0 ) // if count is divisible by 2, begin new line of output (creates two columns)
cout << endl;
} // end if structure
} // end for structure
cin >> count; // state number entered and matches count
***********************************
int lettercount[53];
for ( int i = 0 ; i < 56 ; i++ )
lettercount[count][i]]++;
***********************************
cout << "You've selected " << states[count-1] << " state." << endl;
cout << "Abbreviation is " << abb[count-1] << " and state name length is " << lettercount << endl;
return 0;
}
This code works until I try to implement counting the letters of the states (between the asterisks).