Mail Archives: djgpp/1998/07/09/16:55:22
From: | Endlisnis <s257m AT unb DOT ca>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: File Access in C++ with DJGPP using ifstream
|
Date: | Wed, 8 Jul 1998 15:30:18 -0300
|
Organization: | University of New Brunswick
|
Lines: | 27
|
Message-ID: | <Pine.SOL.3.96.980708152515.16907D-100000@sol.sun.csd.unb.ca>
|
References: | <6nul97$pnk$1 AT news DOT minn DOT net>
|
NNTP-Posting-Host: | sol-alt1.unb.ca
|
Mime-Version: | 1.0
|
In-Reply-To: | <6nul97$pnk$1@news.minn.net>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Tue, 7 Jul 1998, minn.net wrote:
->I am trying to port over some code I wrote for Borland C++ 5.0 to djgpp C++
->but all of my file objects do not read from my files properly. I am looking
->for code examples of file access in djgpp C++ so I can compare my code to
->it. I am also looking for any page that discusses C++ with djgpp, so far
->all I can find is plain C.
I've actually made a pcx loader in BC++v5, and then ported it into
DJGPP fine. The only thing you might have to worry about is variable
allignment. And make sure you are opening it in binary mode, although;
you need to do that in BC++v5 also. Try adding "__attribute__((packed))"
to your definitions of your structs. That will force it to leave no slack
space.
#include <fstream.h>
struct {
char a;
int b __attribute__((packed));
void main()
{
char Stuff[100];
fstream File("filename.ext",ios::in|ios::binary);
File.read(stuff,100);
}
Endlisnis
[I have a pyramid of wingyness]
- Raw text -