i am using below code to check whether alpha numeric chara.
this code breaks at the second line ie at if condition
and shows assertion error
for ( int pos = 0; pos < sInputWord.length(); ++pos )
{
if (isalnum(sInputWord.at(pos)))//if (isalpha(sInputWord.at(pos)))
// if (isalnum(sInputWord.at(pos))) original line
{
iEngFlag++;
}
}
When used with a debug CRT library, isalnum will display a CRT assert if passed a parameter that isn't EOF or in the range of 0 through 0xFF. When used with a debug CRT library, isalnum will use the parameter as an index into an array, with undefined results if the parameter isn't EOF or in the range of 0 through 0xFF.
Just to add to coder777 explanation:
If on your machine char is signed (which it most likely is), and you will use characters from uper ASCII plane (codes 128 - 255), for example if you want neat table borders or are using some non-english codepage, then integral values of such characters will be negative and not in range 00-FF as MS implementation requires.