delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/30/20:56:12

From: beyonddeath <justhunt1234 AT home DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: File errors but where!
Message-ID: <q718esg046rurv75c1c5nd8qqq5nnjejod@4ax.com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 74
Date: Thu, 30 Mar 2000 22:58:39 GMT
NNTP-Posting-Host: 24.112.65.173
X-Complaints-To: abuse AT home DOT net
X-Trace: news2.rdc1.on.home.com 954457119 24.112.65.173 (Thu, 30 Mar 2000 14:58:39 PST)
NNTP-Posting-Date: Thu, 30 Mar 2000 14:58:39 PST
Organization: @Home Network Canada
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am using some code that will work somtimes less times than not,
anyway when it does chances are you cant continue in the game anyway,
the problem is that you save or load and dos gives you a big error
that just says invalid page fault and a lotta numbers.

the code that saves is as follows:

//////////////////////////////////////////////////////////////////////
// Author: Justin Hunt
// Version: 00.00.55
// Date: 29/03/2000
// Short Description: This is the finnally implemented saving script
//////////////////////////////////////////////////////////////////////
FILE * fptr;
int size1 = sizeof(player);
int size2 = sizeof(days);
int size3 = sizeof(stocks);
void dosave()
{
fptr = fopen("save.dat", "w+");
fseek(fptr, 0L, SEEK_SET);
fwrite(&player , sizeof(player), 1, fptr);
fwrite(&days, size2, 1,fptr);
if(ferror(fptr))
fwrite(&stocks, size3, 1, fptr);
fclose(fptr);
}


void doload()
{
fptr = fopen("save.dat", "r+");
fseek(fptr, 0L, SEEK_SET);
fread(&player, size1, 1, fptr);
fread(&days, size2, 1, fptr);
fread(&stocks, size3, 1, fptr);
fclose(fptr);

doprintbox();
	gotoxy(1,1);
	cprintf("You have");
        doprintbars();
      	gotoxy(30,2);
	cprintf("%d of 10000      ",player.stocks.gm);
      	gotoxy(30,3);
	cprintf("%d of 10000      ",player.stocks.ibm);
      	gotoxy(30,4);
	cprintf("%d of 10000      ",player.stocks.microsoft);
      	gotoxy(30,5);
	cprintf("%d of 10000      ",player.stocks.sony);
      	gotoxy(30,6);
	cprintf("%d of 10000      ",player.stocks.acer);
      	gotoxy(30,7);
	cprintf("%d of 10000      ",player.stocks.rogers);
      	gotoxy(30,8);
	cprintf("%d of 10000      ",player.stocks.shaw);
      	gotoxy(30,9);
	cprintf("%d of 10000      ",player.stocks.panasonic);
      	gotoxy(30,10);
	cprintf("%d of 10000      ",player.stocks.aol);
        gotoxy(1,11);
	cprintf("MONEY:%d         ",player.money);
	gotoxy(1,12);
	cprintf("Balance:%d       ",player.bank.balance);

gotoxy(30, 24);
cprintf("This is day:%d", days);
}

clearly this is in c but this will print some variables after it loads
all defined in other files that i dont want to post (TOO BIG)  any way
is it the structure that screws it up i have the latest djgpp 2.03 if
im not mistaken just downloaded it anyway.  This compiles perfectly
fine but errors as i say while doing it or likely right after.  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019