www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/12/07:34:12

From: "Chia" <chia AT top DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Text in Datafiles
Date: Mon, 12 Jan 1998 06:11:29 -0600
Organization: Home
Lines: 31
Message-ID: <69d1ap$f4h@nnrp4.farm.idt.net>
NNTP-Posting-Host: pm1-25.top.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I've got a program that is an index of collectible cards.  I started this
program when I knew nothing of programming, so it's very kludgy.  Now, I've
started to work on getting the thing up to specs, and I've thought up a
great idea.  Instead of having the card names stored in thousands of
strcpy()'s, I've saved them into a datafile.

I've got this function:

/////////////////////////////////////////////////////////
void load_card_names(void) {
DATAFILE *CardData;
FILE *namefile;
  int count;
  CardData = load_datafile( "cards.dat" );
  namefile = fopen( CardData[cardnames].dat, "r");
  for(count = 0;count < NUM_CARDS;count++) {
  fscanf(namefile, "%s\n", &ALL_CARDS[count].The_Name);      }
fclose(namefile);
}
/////////////////////////////////////////////////////////

which I'm trying to use to copy the card names into a typedef from the
datafile.  ( The typedef struct has the line:  char The_Name[40]; )
I was surprised when it compiled, and even more surprised when it ran and
didn't crash the machine.  The problem is that it copies makes all of the
card names be blank.
Does anybody see anything wrong with this code?  Thanks!

chia AT top DOT net


- Raw text -


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