need help with c programming data validation
-
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
-
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
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.
-
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.
-
it is weirld but i cant seems to use try{} catch{} in c programming the compilr does accept it anybody knows why?