Skip to main content
gamedev.net
🔒 Locked

Problem with loading from files

Started by Zeraan Nov 30, 2002 at 12:18 PM 2 replies 200+ views
Original Post
Zeraan
Zeraan
I'm working on loading scores from a file. I've finished the saving part, and it works well. But when I try to load scores, the game freezes. I'm using stdio's FILE file io. This is my loading code:
    
void TScore::Load()
{
	FILE *inf;

	inf = fopen("Scores.dat", "r");

	for(int i = 0; i < 10; i++)
	{
		fscanf(inf, "%s", names[i]);
		fscanf(inf, "%d", list[i]);
	}

	fclose(inf);
}
    
the first string is name of the player, the 2nd one is for the score itself. The game freezes when I call this function. What did I do wrong? [edited by - Zeraan on November 30, 2002 3:45:49 PM]
stefu
stefu

  
Check if fscanf's returns 1 (in this case)

and it should be &list[i], but cannot be sure cos you don't show much code ;)

and be sure that you have enought space for string in names[i]!!




RacingTREME - Linux ShipBattle


[edited by - stefu on November 30, 2002 4:14:01 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.