How we can convert string to number or number to string?
-
I want to convert a number like (i=3546246547) to a string variable( str='3546246547') and vice versa. How can we do this? Mehdi Hosseinpour
-
I want to convert a number like (i=3546246547) to a string variable( str='3546246547') and vice versa. How can we do this? Mehdi Hosseinpour
try the atoi and _itoa or use CString: CString str; int i = 3546246547; str.Format("%d",i);
-
I want to convert a number like (i=3546246547) to a string variable( str='3546246547') and vice versa. How can we do this? Mehdi Hosseinpour
CString is MFC specific. If you're not creating an MFC application and don't want to bloat your code use the following CRT data conversion routines. strtoul, wcstoul - Converts string to unsigned long integer. _ultoa, _ultow - Converts unsigned long to string. For more data conversion functions search MSDN for "Data Conversion Routines"
-
I want to convert a number like (i=3546246547) to a string variable( str='3546246547') and vice versa. How can we do this? Mehdi Hosseinpour
there is also another way to convert values into strings with the
sprintf()
fonction :#include <string.h>
int sprintf(char* buffer, const char* format, ...);
//...you can use it like printf(), giving it a pointer to where the string will be stored TOXCCT alias Nicolas C.