type conversions
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
http://www.cplusplus.com/ref/cstdlib/[^] ;-) Lord Kixdemp www.SulfurMidis.com www.SulfurSoft.tk [ftp://][http://][hotline://]tsfc.ath.cx
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
Try using some of the numeric conversion functions, for example itoa(), ltoa().
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
Hi arr2arr1arr, maybe it is some helpful to you http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_data_conversion.asp[^]
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
-
how to convert from numeric types (such as double, int, long,...) to char[]? (i want to show the number in a window, so i need to convert it to char)
Hi there. While sprintf works, it is really a C solution. I just wanted to show you a C++ solution for creating a string to display by using streams.
#include // your numerical data double num1 = 3.143; // an output stream std::ostringstream outStream; std::string outString; outStream << "Value of double is : " << num1; // if you want a standard c++ string from the stream outString = outStream.str(); // VC++ stuff. Lets write the string to a label (need to create a System::String) label1->Text = gcnew String(outStream.str().c_str());
Using the ostringstream, you will not have to worry about the size of your char array, or have a ptr to char and do any memory allocation/cleanup. All done for you. Cheers