It depends on the rand() implementation... the standard (POSIX / Single Unix) gives a sample implementation but any system is free to have something better.
You can see the sample code there. If that exact code is used, then the internal state is a 32-bit integer, and it suffices to get two successive 16-bit output values to recompute the internal state. Actually, any 32 bits of output are sufficient, with the generic reconstruction algorithm known as "brute force": it won't take long, for a computer, to try all possible 32-bit internal states until one is found, which matches the observed output. It is possible to recompute the state waaaaaaaaay faster by doing some linear algebra, but since brute force works well, why bother ?
In usual Linux systems, rand() is an alias for random() which is much better, but still not "good", as far as randomness goes. The srandom() function still initializes the internal state with a 32-bit seed, which is amenable to brute force. You just lose the linear algebra shortcuts; or, at least, things require a bit more mathematics. random() is not a cryptographically secure PRNG and its internal state can be rebuilt by observing some output bits. The simplest method is still brute force, and it works well.
(Also, if the application did not bother to call srandom(), then the initial seed is always 1, so brute force will work very well.)
rand(). C is a language, andrand()is a function provided by a library for that language. The libraries that are used are entirely dependant on the compiler suite you're using, because the RNG thatrand()is based on is not mandated by the spec. You'll need to specify which compiler and libraries you're using. – Polynomial Feb 27 at 19:44rand(). If you use say MS Visual Studio with the MS C Run-time library, the rand() function may be implemented completely differently. See: en.wikipedia.org/wiki/C_standard_library#Implementations – dr jimbob Feb 27 at 19:45rand()implementations are horrible beyond believe. They're broken even for basic numerical work. – CodesInChaos Feb 27 at 21:44