Convert a string into a long integer
#include <stdlib.h> long atol( const char* ptr ); long long atoll( const char* ptr );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The atol() function converts the string pointed to by ptr to a long integer; atoll() converts the string pointed to by nptr to a long long integer.
#include <stdlib.h> #include <stdio.h> int main( void ) { long x; x = atol( "-289" ); printf( "x = %d\n", x ); return EXIT_SUCCESS; }
produces the output:
x = -289
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |