Heyy, back again.
another function I need to write checks to see if the characters of a String state code(such as PA) are in uppercase and if they aren't I need to make them uppercase. (so has to check for stuff like pa, Pa, pA and fix it)
the state code HAS to be a String as per prof assignment. (it's in the private of the header file)
I tried converting the string into a character array but I got the error error C2440: 'initializing' : cannot convert from 'class String' to 'char'
I am using tstring and not string as again per prof assignment.
if I could convert it to string I know I can just use if statements to check case and then just shift the char on the ascii chart if the case is wrong, but I don't know how to do this with a String.
so how can I convert the string into 2 chars without saving the data as a char array originally and then convert it back to String?
OR
is there a way of doing this without converting it to char?
prob obvious what I'm doing wrong but again, our class didn't actually get this far I'm just using experience from other languages.(mostly alice and blitz basic)
String PatientDemographicInformation::getPatientState( )
{
char state[2] = {patientState};
String fixState;
if (state[1] >= 97 || state [1] <= 122)
{
state[1] -= 32;
}
else if (state[1] >= 65 || state [1] <= 90)
{
state[1] = state[1];
}
else
{
cerr << "invalid char";
exit(9);
}
if (state[2] >= 97 || state [2] <= 122)
{
state[2] -= 32;
}
else if (state[1] >= 65 || state [1] <= 90)
{
state[2] = state[2];
}
else
{
cerr << "invalid char";
exit(9);
}
fixState = state[1] + state[2];
return fixState;
}