isalpha
function template
<locale>
template <class charT>
bool isalpha ( charT c, const locale& loc );
Check if character is alphabetic using locale
Checks whether c is an alphabetic character using ctype facet of locale loc, returning the same as a call to:
|
use_facet < ctype<charT> > (loc).is (ctype_base::alpha, c)
|
This function replicates the functionality of its C-library equivalent isalpha. See isalpha for more info.
Parameters
- c
- Character to be checked.
- loc
- Locale to be used. Shall have facet ctype present.
Template parameter charT is the character type.
Return Value
true if indeed c is an alphabetic character, false otherwise.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
// isalpha example (C++)
#include <iostream>
#include <string>
#include <locale>
using namespace std;
int main ()
{
locale loc;
string str="C++";
for (string::iterator it=str.begin(); it!=str.end(); ++it)
{
if (isalpha(*it,loc)) cout << "character " << *it << " is alphabetic\n";
else cout << "character " << *it << " is not alphabetic\n";
}
return 0;
}
|
Output:
character C is alphabetic
character + is not alphabetic
character + is not alphabetic
|
See also
ctype | Character type facet (class template) |
isalnum | Check if character is alphanumeric using locale (function template) |
isdigit | Check if character is a decimal digit using locale (function template) |
|