how uppercase and lowercase be identified as one variable type?

Sorry, I really do not have idea on how to make the uppercase and lowercase be identified as one variable type. For example a == A . I don't have any background idea on ASCII but I have made this code that would show how many times an alphanumeric character may appear in a sentence of only 25 characters in maximum.

//my codes
#include <iostream>
#include <string>
using namespace std;

int main ()

{
char searching='\0';
string sentence="";
char string [25];
int counter = 0, i;

cout <<"Enter a sentence : " <<endl;
getline (cin, sentence);
cout<<"Which letter would like to count the number it times appears: "<<endl;
cin>>searching;
for (int i=0; i<sentence.length(); i++)
{
if (sentence [i]== searching)
{
counter++;
}
}
cout<<"the letter '" <<searching << "' appears " << counter << " times "<< endl;

return 0;

}


Hi, you can simply "preprocess" every letter with tolower (http://www.cplusplus.com/reference/cctype/tolower/ ) or toupper function.
Last edited on
Thank you very much! :)
Topic archived. No new replies allowed.