If you're curious about how it works, there's a book called The C Standard Library which discusses the design and implementation of this and other functions. Of course, you could also take a gander at ...