I don't know if this approach is better or more correct than your approach but it's different.

Code:

#include <stdio.h>
#include <malloc.h>
int main(void)
{
int this_number = 3, position = 0,divisor, not_prime, index;
int *array = NULL;
while(this_number < 10000)
{
divisor = this_number >> 1;
not_prime = 0;
while(divisor > 1)
{
if(!(this_number % divisor))
{
divisor = !divisor;
not_prime = 1;
}
else
divisor -= 1;
}
if(!not_prime)
{
if(!position)
array = malloc(sizeof(int) * 1);
else
realloc(array, sizeof(int) * position+1);
array[position] = this_number;
position +=1;
}
this_number += 1;
}
for(index = 0; index < position; index++ )
{
if(*(array+index+1) - *(array+index) == 2)
{
printf ("%d and %d are prime pairs.\n",*(array+index) ,*(array+index+1) );
}
}
if(array)
free(array);
return 0;
}