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?
Asked
Active
Viewed 1,146 times
2 Answers
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:
- Create
glibc-source
directory withmkdir glibc-source
andcd glibc-source
- run
apt-get source glibc
- 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 isglibc-2.23/stdlib/atoi.c

Sergiy Kolodyazhnyy
- 105,154
- 20
- 279
- 497
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
- 1
- 7
glibc
is essential part of the Ubuntu as operating system, and knowing how certain functions are implemented is essential for developers and learners, and it's partially related to obtaining source code of programs that are standard to Ubuntu. I'd caution against hasty close-voting. – Sergiy Kolodyazhnyy Oct 16 '17 at 05:31