atoi
![]() |
![]() |
![]() |
![]() |
atoi()
Convert a string into an integer
Synopsis:
#include <stdlib.h> int atoi( const char* ptr );
Arguments:
- ptr
- A pointer to the string to parse.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The atoi() function converts the string pointed to by ptr to an int.
Returns:
The converted integer.
Examples:
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
int x;
x = atoi( "-289" );
printf( "x = %d\n", x );
return EXIT_SUCCESS;
}
produces the output:
x = -289
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | Yes |
| Signal handler | Yes |
| Thread | Yes |
See also:
atol(), itoa(), ltoa(), sscanf(), strtol(), strtoul(), ultoa(), utoa()
![]() |
![]() |
![]() |
![]() |
![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)