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,284 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-sourcedirectory withmkdir glibc-sourceandcd glibc-source - run
apt-get source glibc - Once
apt-getis 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
- 107,582
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