3

I was wondering where I can find the actual C implementation of atoi() (or other such functions). I looked into stdlib.h but it seems like atoi is not implemented there. Is there a way to view the libc source tree and see the actual C code?

ItM
  • 233

2 Answers2

4

Obtaining glibc code can be done via apt-get command. Here's basic process done in terminal, which takes no longer than 5 mins:

  1. Create glibc-source directory with mkdir glibc-source and cd glibc-source
  2. run apt-get source glibc
  3. Once apt-get is done, you'll have 3 files and one directory, glibc-2.23/, glibc_2.23-0ubuntu3.dsc, glibc_2.23-0ubuntu3.debian.tar.xz, glibc_2.23.orig.tar.xz. The file you want is glibc-2.23/stdlib/atoi.c
1

Actually found it in the git repo here: https://github.com/lattera/glibc/search?utf8=%E2%9C%93&q=atoi&type=

Leaving this here to help anyone else who might wonder this in the future.

ItM
  • 233