Here's a challenge for you C++ aces. The challenge is to write a function with the following declaration:

`unsigned long extract_digits ( unsigned long x, size_t n, size_t i );`

This challenge has three parts.

**Part I (Beginner):**

Write the extract_digits function. It should return a sub-value of the first parameter consisting of n digits starting at i. For example, the first 3 digits of 12345 starting at 1 should return 234.

**Part II (Intermediate):**

Make the extract_digits function as solid as possible given unexpected input.

**Part III (Expert):**

Make the extract_digits function as fast as possible.

There's no need to submit the solution when you're finished. This is a personal challenge, not a contest. However, programmers are a naturally competitive species, so if enough people post solutions to this thread, I'll judge them and maybe even give away a prize. :)