This works for me (without optimizations).
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int n = 0;
int guess=0;
char answer[14];
srand(time(0));
guess = rand();
do {
unsigned char *p = (unsigned char*)&guess;
printf("actual is %d", guess);
printf(" (%02x %02x %02x %02x)\n", p[0], p[1], p[2], p[3]);
printf("Input a number: ");
fgets(answer, 20, stdin); // enter: 808464432 0000
// (that's 5 spaces before the zeroes)
p = (unsigned char*)&guess;
printf("actual is %d", guess);
printf(" (%02x %02x %02x %02x)\n", p[0], p[1], p[2], p[3]);
n = atoi(answer);
printf("guess is %d\n", n);
if (n == guess)
break;
printf("Incorrect! Guess again (y/n)? ");
fgets(answer, 4, stdin);
}
while (answer[0] == 'y');
return 0;
}
Note that the ascii code for '0' is 0x30, and 0x30303030 is 808464432.
(Obviously I'm assuming 4-byte ints and that guess starts right after the 14-byte answer array, which seems to be the case for me.)
Have you given up on the other program?
Do you know the answer?
If there is an online link associated with it, post it.
Also, always post an entire program, complete with headers.
And avoid posting pictures. Instead, copy and paste the text of terminal output.