How to give validation for a character string in c++?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dismipaul
    New Member
    • Aug 2013
    • 1

    How to give validation for a character string in c++?

    If i have character string 'char name[30]' how to give validation for the name entered by user?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Just compare the name that was entered to your validation criteria. So if the name needs to be capitalized, make sure name[0] is upper case, etc...

    Comment

    • buy phone
      New Member
      • Aug 2013
      • 8

      #3
      Do not use array of characters, use String class.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The OP is using a char array and not a string class. Unless the OP asks for advice on programming techniques, don't provide an opinion.

        Comment

        • anonuser
          New Member
          • Aug 2013
          • 6

          #5
          i think you're asking how to validate the content of name - if so, take a look at the isxxx functions, eg., isalpha, and friends. if you need something more complex, try regex().

          do you have special requirements for the content of name[]?
          Last edited by anonuser; Aug 31 '13, 07:56 PM. Reason: afterthought

          Comment

          Working...