Mail Archives: djgpp/1996/05/31/22:33:51
| Xref: | news2.mv.net comp.os.msdos.djgpp:4423
|
| From: | jpdelprat AT teaser DOT fr (Jean-Pierre)
|
| Newsgroups: | comp.os.msdos.djgpp
|
| Subject: | Packed structures
|
| Date: | Fri, 31 May 1996 05:41:23 GMT
|
| Organization: | Guest of France-Teaser
|
| Lines: | 29
|
| Message-ID: | <4om7pk$6n1@teaser.fr>
|
| NNTP-Posting-Host: | clt-e26233c2.teaser.fr
|
| To: | djgpp AT delorie DOT com
|
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hello,
There were many messages about a bug in C++ with packed structures a
few time ago. I've forgotten the solution. It seems to me that i have
to use #pragma packed(1) but i can't manage to have this program work.
#include <stdio.h>
#pragma packed(1)
#include <dir.h> // struct ffblk is packed
#pragma packed(0)
int main(void)
{
struct ffblk ffblk;
int done;
printf("Directory listing of *.*\n");
done = findfirst("*.*",&ffblk,0);
while (!done)
{
printf(" %s\n", ffblk.ff_name); // ff_name is too bytes to big ->
the first two characters of the filename are lost
done = findnext(&ffblk);
}
return 0;
}
- Raw text -