Comparison between character and number.

Environment : Visual C++

Can anyone give me the codings on how do i determen each character in terms of the type.

For example :

SE100

S=Character
E=Character
1=Number
0=Number
0=Number


I want to evaluate and see weather S is a character, E is a character, 1 is a number and as follows.


Regards

Eugene

eugene007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi
take each char and check with function IsAlpha(ch) it will return no zero if its alphabet or if its any other thing other than alphabet it returns zero
U can use isalnum to check for number if isalpha returns 0

char ch[5] = "SE100";
for (int i = 0; i<=4 ; i++)
 if (isalpha(ch[i]))
// alphabet
else
 if(isalnum(ch[i])
     //Number

Hope this helps
anuy way what happened to select statement U did not give structure?
Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
inprasCommented:
A program?
here itis
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void main( void )
{
      char chStr[10] = "SE100";
      int k = strlen(chStr);
      for (int i = 0; i <= k ; i++)
      {
            if (isalpha(chStr[i]))
                  printf("Character\n");
            else
                  if(isalnum(chStr[i]))
                        printf("Number\n");
      }
}
Regards
0
eugene007Author Commented:
Hi inpras...sorry that i did not send you that comment...because busy for christmas...ill send it to you as soon as possible..and thanks for the cooding its working great.

Regards

Eugene
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.