Sunday, July 26, 2009

How to convert numbers to string in C?

Ive used itoa() function.. But it can only convert numbers upto 10 digits... What is the better function to use than this to input long double variable types rather than integer? Please help...

How to convert numbers to string in C?
Why not just use something like





#include string





string numbers;





numbers = 98431658736521876586;





Strings can be as long as you want them to be with the exception of white space and special characters. Why bother using the itoa() function in the first place?
Reply:you can use atol or strtol. if you program uses unsigned integers, you can also use strtoul
Reply:enter the number as string.


or a digits array then use concatination.








to convert a string to a long number use


atol( )





to convert a string to a double number use


atof()


No comments:

Post a Comment