Something like
int got;

do {
got = beg(); /* function returns non-zero if it has gotten what was begged for */
} while (got == 0);