Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I valid if all characters are letters and length

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to valid that a string of characters are all alpha numeric, and that the string does not exceed 10 char.

I know that I use isalpha but not sure how, also not sure how to use strlen.

can someone help me
 
if your string is of type CString use GetLength() to determine the stringlength.
for checking the content use CStrings MID-Function to
the strings characters.
with type char use strlen for the string length and use
second pointer to access the strings characters.
Hope it helps.
 
a sample code:

bool validateString(char * aStr)
{
int n = strlen(aStr);
if (n > 10 ) return 0;
for (int i=0; i< n ; i++)
if (!isalpha(aStr)) return 0;
return 1;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top