Posts

Showing posts from June, 2019

Tricky Situation: strtod function converting strings to inf or nan

Image
This blog post discuss about a tricky situation which can happen when using strtod function. Strtod function interprets the contents of string as a floating point number and return its value as a double. The declaration of strtod function is as shown below: Declaration double strtod(const char*str, char **end) str ->  It represents the value of the string which is to be converted. end -> It is the reference to an already allocated object of type char* Similar to the post about atof function , strtod function also converts the string to inf or nan if the string starts with "inf" or "nan". This can cause downstream impacts if the converted value is passed to database. The following program depicts this issue: Similar Posts: Tricky Situation when using atof function Anonymous classes in C++ Sets in C++ made easy