rand() uses whichever RNG is supplied in whichever C library was used to compile the executable. And some of them are pretty crappy (I guess they're just not intended for serious random number generation, just "good enough" for occasional purposes). As bradgrafelman notes, mt_rand() is much better, though not for the reason he gives: the Mersenne Twister is just as pseudorandom as whatever algorithm (probably linear-congruential) that your rand() is using.
In fact, I'm guessing that you're testing this on a Windows machine. The standard rand() function there is particularly crappy. Not only does it only produce a sixteen-bit number, but it only uses the previous (sixteen-bit) value to determine the next value. Which means that it can't ever produce a sequence longer than 215=32768=8*(4095+1) terms before it starts repeating itself.
The careful reader would have wondered why "15" and not "16" there. Joy of joys, Windows uses a signed sixteen-bit integer, and then ignores the sign bit for RNG purposes.
The Mersenne Twister retains a lot more than sixteen bits of history, and under typical conditions has a period of 219937-1; so it should take somewhat longer to start repeating. (It's also platform-independent, which it doesn't hurt to have.)