Mail Archives: djgpp/1998/01/29/20:15:27
Message-ID: | <34D0FA3F.9B8BD192@csun.edu>
|
Date: | Thu, 29 Jan 1998 13:53:03 -0800
|
From: | Ryan Bright <rmb56313 AT csun DOT edu>
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Simultaneous Datafiles in Allegro
|
References: | <MPG DOT f3aa7216d220b029896c0 AT news>
|
NNTP-Posting-Host: | s253n102.csun.edu
|
Organization: | California State University, Northridge
|
Lines: | 59
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Solution at bottom.
Nitpicks up top.
Matt Riker wrote:
>
> Hello:
>
> I've spent much time trying to figure out why my program won't
> successfully open a second datafile while one is already opened.
[clip]
> strcpy(get_filename(buf), "c:/maped/maped.dat");
First off, you haven't told us what buf is, but I'm just gonna take a
wild guess and assume that you cut n' pasted it straight out of the
examples and, as a result, it's an uninitialized string. If buf is
automatic (local), then it could easily be filled with junk.
> maped_datafile = load_datafile(buf);
Secondly, as Shawn mentioned already, try :
maped_datafile = load_datafile("c:/maped/maped.dat");
But you should keep in mind that if anyone else uses this program,
chances are pretty good that it won't be in C:/maped/, so consider just
using :
maped_datafile = load_datafile("maped.dat");
Which assumes that maped.dat is in the current working directory--a more
likely assumption than the first.
> if (!maped_datafile) {
> allegro_exit();
> printf("Error loading MAPED.DAT!\n\n");
> return 1;
Actually, I think you're supposed to use 'return EXIT_FAILURE;' (defined
in STDLIB.H) here. I know this isn't a C newsgroup, but whatever.
> }
>
> strcpy(get_filename(buf), "c:/maped/testspr.dat");
> user_datafile = load_datafile(buf);
This is actually, probably, where your problem lies. I'll assume that
buf is global.
Global variables, like buf, are initialized to zero.
Then, you get_filename a zero'd array, returning the first position.
buf = ""
You copy the name of the first datafile
buf = "c:/maped/maped.dat"
You load that datafile successfully.
Then, you get_filename buf, returning a pointer to "maped.dat"
Then, you copy in the name of the second datafile to that position.
buf = "c:/maped/c:/maped/testspr.dat"
I doubt that file exists.
-Ryan
- Raw text -