I believe you can achieve the 'effect' of setting the maximum number of open file descriptors to 'infinite' by using the following (untested code!):
<snip>
#include <sys/time.h>
#include <sys/resource.h>
struct rlimit rlim;
rlim.rlim_cur = RLIM_INFINTY;
rlim.rlim_max = RLIM_INFINITY;
int ret = setrlimit(RLIMIT_NOFILE, &rlim);
</snip>
Note that what Peter pointed out is more or less correct. You can't actually have infinite file descriptors. The above code just ensures that the kernel won't perform any checks on the number of open file descriptors. So, if you hit a real resource limit; like no more memory left for opening files, you would still get an error. My feeling is that this isn't a wise thing to do. It's always better to know a precise number of the upper limit rather than an arbitrarily large number.
~ Gaurav