OK, I wrote a function that receives two number ranges (say 1 to 1 million), and the address of a counter variable. All values are unsigned long long.
Code:
// prototype
u_long_64 *semiprimegen(u_long_64 first_range, u_long_64 second_range, u_long_64 *semiprimes_count);
The function will generate semi-prime numbers, allocating the first bunch of memory and reallocating as needed, modifying the counter variable until the ranges are met, sorts the allocated memory, and returns a pointer to that memory, which contains *semiprimes_count elements of type unsigned long long.
So, In my main function, I have this:
Code:
semiprimes = semiprimegen(first_range, second_range, &semiprimes_count);
Now, after this statement, I accessed the semiprimes_count variable. It works, info is there like its supposed to. I can see the address the semiprimes pointer has (confirmed by printing to console right before semiprimes function returns). But I CAN'T access the memory! What is wrong with this? The printf I put is:
Code:
printf("20th semiprime is %I64u\n", *(semiprimes + 19));
The program crashes right there. In that printf. Anybody knows what's wrong? Thanks.