#include <stdio.h>

void main()
{
	int age = 38;
	int guess = 0;
	int turns = 0;
	int bestscore;

	//Welcome, show current best score (read from file)
	FILE *fp;
	fp = fopen("myfile.txt", "r");
	fscanf(fp, "%d", &bestscore);
	fclose(fp);
	printf("Welcome, the current best score is %d \n", bestscore);

	while (age != guess)  //while not equal to
	{
		printf("Guess Adam's age: ");
		scanf("%d", &guess);

		if (age == guess)
		{
			printf("Well done\n");
		}
		else
		{
			printf("Try again!\n");
		}
		turns = turns + 1;
	}
	printf("You took %d turns\n", turns);

	if (turns < bestscore)
	{
		fp = fopen("myfile.txt", "w");
		fprintf(fp, "%d", turns);
		printf("Well done, a new high score");
		fclose(fp);
	}

	//write any new best score to file
}