ltoa

Converts a long integer to a string

Local Servers:nonblocking
Remote Servers:N/A
Classification:Other
Service:String Conversion

Syntax

  #include <stdlib.h>  
   
  char *ltoa  (  
     long int   value,   
     char      *buffer,   
     int        radix);
  

Parameters

value
(IN) Specifies the integer value to be converted.
buffer
(OUT) Points to the character array.
radix
(IN) Specifies the base to be used when converting the integer.

Return Values

ltoa returns a pointer to the result.

Remarks

The ltoa function converts the integer value into the equivalent string in base radix notation, storing the result in the character array pointed to by buffer. A NULL character is appended to the result. The size of buffer must be at least 33 bytes when converting values in base 2. If the value of radix is 10 and value is negative, then the result is prefixed with a minus sign (-).

See Also

atol, strtol, strtoul, ultoa

Example

  #include <stdlib.h>  
   
  void print_value (long value)  
  {  
     int    base;  
     char   buffer[33];  
     for (base=8; base<=16; base=base+2)  
        printf ("%2d %s\n", base, ltoa ( value, buffer, base ) );  
  }
  

produces the following:

   8 30735  
  10 12765  
  12 7479  
  14 491b  
  16 31dd