Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. need help with c programming data validation

need help with c programming data validation

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neodeaths
    wrote on last edited by
    #1

    hi i am trying to make a input data validation. what i am trying to do is when data is inputed it is inputed first as a string(char[]) then i need to convert the string to an int or an float or etc... after i check that it is a valid int and such. so my question is if there is any function like: int isvalid<== check weahter an string is a valid int convert string to int <== convert the valid string into a inv same for floar and others.. please help i think this is a very useful code to learn

    M 1 Reply Last reply
    0
    • N neodeaths

      hi i am trying to make a input data validation. what i am trying to do is when data is inputed it is inputed first as a string(char[]) then i need to convert the string to an int or an float or etc... after i check that it is a valid int and such. so my question is if there is any function like: int isvalid<== check weahter an string is a valid int convert string to int <== convert the valid string into a inv same for floar and others.. please help i think this is a very useful code to learn

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      The are two ways to check whether a string is a valid int: 1) try to convert it and catch any failure conditions. 2) write your own string analysis or perhaps make use of a regular expression implementation to do some kind of custom check on the string. Look for functions like atoi, atod, atof, strtod? for converting C character array type strings to ints floats and doubles.

      Nothing is exactly what it seems but everything with seems can be unpicked.

      N 1 Reply Last reply
      0
      • M Matthew Faithfull

        The are two ways to check whether a string is a valid int: 1) try to convert it and catch any failure conditions. 2) write your own string analysis or perhaps make use of a regular expression implementation to do some kind of custom check on the string. Look for functions like atoi, atod, atof, strtod? for converting C character array type strings to ints floats and doubles.

        Nothing is exactly what it seems but everything with seems can be unpicked.

        N Offline
        N Offline
        neodeaths
        wrote on last edited by
        #3

        it is weirld but i cant seems to use try{} catch{} in c programming the compilr does accept it anybody knows why?

        D 1 Reply Last reply
        0
        • N neodeaths

          it is weirld but i cant seems to use try{} catch{} in c programming the compilr does accept it anybody knows why?

          D Offline
          D Offline
          DoomedOne
          wrote on last edited by
          #4

          try{} catch{} are C++ not C you shoud tyr __try __except ( ) instead Warning __try __except is Microsoft Specific so it don't work in other compilers

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups