the tolower and toupper return integer and they take integer as argument. you cannot convert whole string abrev at a time. Instead you can do the following
1 2 3
for(int i = 0; abrev[i]!='\0'; i++){
abrev[i] = toupper(abrev[i]);
}
1. Use Bibek's code to convert string to uppercase.
2. Use a switch statement rather than all those nested if statements.
3. Put the cout << State << endl; inside the switch statement rather than at the end. and Default: cout << "Invalid abbreviation."<<endl;. Otherwise, like Meerkat said it will always ouput State, regardless of whether or not it is valid or invalid.
It was actually Maese that had said that but anyway. I would pretty much agree with stridexr, but depending on how you want it to work, you might want to put most of it within a while loop, so that if there is an invalid abbreviation it takes you back to the start to try another input, if that's the case, you could keep cout << State << endl; at the end, just make sure it's after the while loop. That said, you might not want your program to work like this, in which case, stridexr is spot on.
No, only integral types (including char and excluding floating-points types) can be used with the switch.
My bad, I tend to mix up C++ with C# sometimes. Thanks for pointing that out Formwork :))
Anyway, back to the problem:
You could do it with Maps, but I think the most efficient way to do it in your case (especially if this is a school assignment, which it probably is and you are not allowed to use Maps), is to create two parallel string arrays in which the location of the abbreviation and its state reside in the same location in their respective arrays.