Thursday 14 February 2013

atoi(), atof() Standard String to Numeric Conversion Functions


atoi()


This function returns the int type value of a string passed to it and the value() in case the string does not begin with a digit.

For example, if the array str1 contains the string "1234", then the following statement:

y = atoi(str1);

will cause y to have the value 1234.

However, if the array str1 contains the string "ABC", then the following statement:

y = atoi(str1);

will cause y to have the value().

atof()


This function returns the double type value of a string passed to it and the value 0 in case the string does not begin with a digit or a decimal point.

For example, if the array str1 contains the string "1234", then the following statement:

y = atof(str1);

will caluse y to have the value 1234.0000.

However, to use atof(), the following declaration must be included in the program:

double atof();

since it returns a non-integer value.

0 comments:

Post a Comment

Powered by Blogger.