Neelima
asked on
convert float/double to string.
How do I convert a floating point number to string?
Try this (Converting int to string)
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num=999;
char str[6]; // a 5 character string
sprintf(str, "%d", num);
printf("%s\n", str);
return EXIT_SUCCESS;
}
Notice of the use of %d for integer. Change that to others for double and long.
hongjun
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int num=999;
char str[6]; // a 5 character string
sprintf(str, "%d", num);
printf("%s\n", str);
return EXIT_SUCCESS;
}
Notice of the use of %d for integer. Change that to others for double and long.
hongjun
You might wish to see this as well.
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20162003
hongjun
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20162003
hongjun
ASKER
If I use those options then there is rounding after 6 digits after the decimal point.I dont want that.And I dont want to give any precision too.What I want to know is if this can be manipulated at bit level?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER