Convert a number into a string.

Convert a number into a string. From the number i the string 'i' will be produced.

Name Type Default Description
Return char*   Pointer to a static string. The result will be overridden by a subsequent call to this function.
i int - Create a string representation of this number
char	s[256];
int 	i	= 1231
strcpy (s, itoa (i+3)); showmessage (s); // 1234

Data type int is 64bit aware. Here's an example with integers greater than 32 bit:

int main ()
{
    int    	a 		= 6917529027641081856;
    char  *	astr	= "6917529027641081856";
wlog ("", "a=%d\t(and as string '%s')\n", a, itoa (a)); wlog ("", "a=0x%x\t(and as string '%s')\n", a, itoa (a)); wlog ("", "astr='%s'\t(and as int %d)\n", astr, val (astr)); wlog ("", "astr='%s'\t(and as int 0x%x)\n", astr, val (astr));
wlog ("", "string compare : a ?= astr : %d\n", (a == val (astr))); wlog ("", "int compare : a ?= astr : %d\n", strcmp (itoa (a), astr)==0);
return 0; } // Ausgabe // //a=6917529027641081856 (and as string '6917529027641081856') //a=0x6000000000000000 (and as string '6917529027641081856') //astr='6917529027641081856' (and as int 6917529027641081856) //astr='6917529027641081856' (and as int 0x6000000000000000) //string compare : a ?= astr : 1 //int compare : a ?= astr : 1

Of course, the above example willstill work, if the intergers are given as hex values.

int main ()
{
    int    	a 		= 0x6000000000000000;
    char  *	astr	= "0x6000000000000000";
wlog ("", "a=%d\t(and as string '%s')\n", a, itoa (a)); wlog ("", "a=0x%x\t(and as string '%s')\n", a, itoa (a)); wlog ("", "astr='%s'\t(and as int %d)\n", astr, val (astr)); wlog ("", "astr='%s'\t(and as int 0x%x)\n", astr, val (astr));
wlog ("", "string compare : a ?= astr : %d\n", (a == val (astr))); wlog ("", "int compare : a ?= astr : %d\n", strcmp (itoa (a), astr)==0);
return 0; } // Ausgabe // //a=6917529027641081856 (and as string '6917529027641081856') //a=0x6000000000000000 (and as string '6917529027641081856') //astr='0x6000000000000000' (and as int 6917529027641081856) //astr='0x6000000000000000' (and as int 0x6000000000000000) //string compare : a ?= astr : 1 //int compare : a ?= astr : 1

Since

Available
priint:comet InDesign® Plug-Ins, comet_pdf, Illustrator

See Also
val

Alphabetic index HTML hierarchy of classes or Java