How to check if String consist of numeric or alphabet in C

I need some help in Identifying the string. I have incoming string like this *H1999999#it can vary from *H1000000#~*H1999999# sometimes it is *H1FINE# or *H1MED# or any other text in between.Now what I have already done is I have parsed the numeric string and copied the integer value to a buffer. Here is the code for that.

        char H1subbuff[10];
        char head1[4];
        char Initial[2];

        char *ptr;

        memcpy(Initial, &rec[0], 1 );
        Initial[1] = '\0';

        memcpy(head1, &rec[0], 3 );
        head1[3] = '\0';

        if ((strcmp(head1,"*H1") == 0) && (rec[9] == '#'))  
            memcpy(H1subbuff, &rec[3], 6 );
            H1subbuff[6] = '\0';

            H1Val = strtol(H1subbuff, &ptr, 10);

            //Display H1VAL

Now my query is how can check if the String consist of Number or Alphabet.All I need to check if the Portion between *H1 and # is numeric or Alphabet, if it is a numeric I can use strtol() to copy the int value into an buffer.** How can I copy the alphabet or text into an buffer?

Note :- The above two string doesn't have same string length.**

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!