c - how to convert a double value into scientific notation and store it in a string -
this question has answer here:
i know while printing can convert regular number scientific notation using %e , there way convert scientific notation , store in string . can same string converted decimal notation ?
i intend convert , print number entered user scientific notation , add entered number , display final result . entered numbers in decimal notation , output in scientific notation.
yes, there sprintf()
, , snprintf()
this
char string[100]; int result; double value; value = 1e-3; result = snprintf(string, sizeof(string), "%e", value); if ((result < 0) || (result >= sizeof(string))) error_please_dont_use_string(); // return or else fprintf(stdout, "%s\n", string);
Comments
Post a Comment