C Language: Atoi Function (Convert String To Integer) - TechOnTheNet

TechOnTheNet Logo
  1. Home
  2. C Language
  3. Standard Library Functions
  4. stdlib.h
totn C Functions C Language: atoi function(Convert String to Integer)

In the C Programming Language, the atoi function converts a string to an integer.

The atoi function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.

Syntax

The syntax for the atoi function in the C Language is:

int atoi(const char *nptr);

Parameters or Arguments

nptr A pointer to a string to convert to an integer.

Returns

The atoi function returns the integer representation of a string. The atoi function skips all white-space characters at the beginning of the string, converts the subsequent characters as part of the number, and then stops when it encounters the first character that isn't a number.

Required Header

In the C Language, the required header for the atoi function is:

#include <stdlib.h>

Applies To

In the C Language, the atoi function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the atoi function:

  • atof function <stdlib.h>
  • atol function <stdlib.h>
  • strtol function <stdlib.h>
  • strtoul function <stdlib.h>

See Also

Other C functions that are noteworthy when dealing with the atoi function:

  • strtod function <stdlib.h>
Share on:

Databases

  • SQL
  • Oracle / PLSQL
  • SQL Server
  • MySQL
  • MariaDB
  • PostgreSQL
  • SQLite

MS Office

  • Excel
  • Access
  • Word

Web Development

  • HTML
  • CSS
  • JavaScript
  • Color Picker

Programming

  • C Language

More

  • ASCII
  • Unicode
  • Linux
  • UNIX
  • Techie Humor
clear filter right caret

C Language

  • Introduction
  • Compiling and Linking
  • File Naming
  • Preprocessor Directives
  • #include
  • #define
  • #undef
  • #if
  • #ifdef
  • #ifndef
  • #elif
  • #else
  • #endif
  • #warning
  • #error
  • Comments
  • Variables
  • Integer Variables
  • Float Variables
  • First Program
right caret

assert.h Functions

  • assert
right caret

ctype.h Functions

  • isalnum
  • isalpha
  • iscntrl
  • isdigit
  • isgraph
  • islower
  • isprint
  • ispunct
  • isspace
  • isupper
  • isxdigit
  • tolower
  • toupper
right caret

locale.h Functions

  • localeconv
  • setlocale
right caret

math.h Functions

  • acos
  • asin
  • atan
  • atan2
  • ceil
  • cos
  • cosh
  • exp
  • fabs
  • floor
  • fmod
  • frexp
  • ldexp
  • log
  • log10
  • modf
  • pow
  • sin
  • sinh
  • sqrt
  • tan
  • tanh
right caret

setjmp.h Functions

  • longjmp
  • setjmp
right caret

signal.h Functions

  • raise
  • signal
right caret

stdarg.h Functions

  • va_arg
  • va_end
  • va_start
right caret

stdio.h Functions

  • clearerr
  • fclose
  • feof
  • ferror
  • fflush
  • fgetc
  • fgetpos
  • fgets
  • fopen
  • fprintf
  • fputc
  • fputs
  • fread
  • freopen
  • fscanf
  • fseek
  • fsetpos
  • ftell
  • fwrite
  • getc
  • getchar
  • gets
  • perror
  • printf
  • putc
  • putchar
  • puts
  • remove
  • rename
  • rewind
  • scanf
  • setbuf
  • setvbuf
  • sprintf
  • sscanf
  • tmpfile
  • tmpnam
  • ungetc
  • vfprintf
  • vprintf
  • vsprintf
down caret

stdlib.h Functions

  • abort
  • abs
  • atexit
  • atof
  • atoi
  • atol
  • bsearch
  • calloc
  • div
  • exit
  • free
  • getenv
  • labs
  • ldiv
  • malloc
  • mblen
  • mbstowcs
  • mbtowc
  • qsort
  • rand
  • realloc
  • srand
  • strtod
  • strtol
  • strtoll
  • strtoul
  • system
  • wcstombs
  • wctomb
right caret

string.h Functions

  • memchr
  • memcmp
  • memcpy
  • memmove
  • memset
  • strcat
  • strchr
  • strcmp
  • strcoll
  • strcpy
  • strcspn
  • strerror
  • strlen
  • strncat
  • strncmp
  • strncpy
  • strpbrk
  • strrchr
  • strspn
  • strstr
  • strtok
  • strxfrm
right caret

time.h Functions

  • asctime
  • clock
  • ctime
  • difftime
  • gmtime
  • localtime
  • mktime
  • strftime
  • time

Home | About Us | Contact Us | Testimonials | Donate

While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.

Copyright © 2003-2026 TechOnTheNet.com. All rights reserved.

Tag » What Is Atoi In C