checking for characters

I have a string that I need to analyze.
How would I be able to tell if there are any characters in the string?  I basically need to make sure there are only numbers in the string and no alpha characters.
ie
121342  is good
124a32  is bad

Thanks for your help.
andrew161Asked:
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.

andrew161Author Commented:
Adjusted points to 150
0
nietodCommented:
you can use the isalpha() function contained in <ctype.h> to test each character

example follows.
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
nietodCommented:
bool IsAlphaString(const string &S)
{
   const int Len = S.length();

   for (int i = 0; i < Len; ++i)
        if (isalpha(S[i]))
           return true;
   return false;
}
0
nietodCommented:
Actually, that only makes sure that there are no letters.  That doesn't test for spaces and symbols. If you only want digts you need to use isdigits(), like

bool isDigitString(const string &S)
{
   const int Len = S.length();

   for (int i = 0; i < Len; ++i)
      if (!isdigit(S[i]))
         return false;
   return true;
}

let me know if you have any questions.
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
C++

From novice to tech pro — start learning today.