This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

atoi

Prototype

#include <stdlib.h>

int atoi(const char *s);

Description

Converts the argument string s to an integer. Returns the converted value of the input string s.

Example

View source
#include <stdio.h>
#include <stdlib.h>

/*
 * twotimes.c: print the argument number multiplied by 2.
 * usage: twotimes <number>
 */
int main(int argc, char **argv)
{
    if (argc > 1)
	printf("Two times %s is %d\n", argv[1], atoi(argv[1]) * 2);

    return EXIT_SUCCESS;
}

References

ISO C 9899:1990 7.10.1.2