Prime Factors (32 bits, without Sieve)
You don't need an exhaustive search: \$2*3*5*7*11*13*17*19*23*29 = 6469693230 &gt; 2^{32}\$, so it is safe to allocate 9 slots.



primeExponents does too much and shall be split into three functions, one to factorize a number, another to validate factorization, and yet another to print it.



The factorization logic is extremely hard to follow. Consider instead

void factorize(int num, factors_t * factors, int * primes)
{ 
  for (; num &gt; 1; ++primes) {
    factors-&gt;prime = *primes;
    factors.exponent = 0;

    while (num % *primes == 0) {
      factors-&gt;exponent++;
      num /= **primes; // Edit: shame on me.
    }

    if (factors-&gt;exponent &gt; 0) {
      factors++;
    }
  }
}