Mail Archives: djgpp/2000/08/24/17:45:36
Nate Eldredge wrote:
> yhvhboy1 AT home DOT com writes:
>
> > assuming there's a few people out there that
> > know both perl and c -- i ask you this:
> > how do we store and retrieve __DATA__ in c?
>
> What is __DATA__? If it's a perl term, it's one beyond my experience.
in perl:
#!/usr/bin/perl
open(OUTFILE, ">c:/windows/my_outfile");
binmode(OUTFILE);
binmode(DATA);
while (read(DATA, $_, 1)) {
print OUTFILE $_;
}
# everything after __DATA__ is just contents of a file i'd like to save
# into c:\windows\my_outfile - can be binary or ascii
# we use binmode() to force binary (if that's what it is)
# the DATA filehandle is opened to read everything after __DATA__
# by default when our perlscript is compiled.
__DATA__
BMö‘ 6 ( ½ ½ À� Î Ä €€€ € €€ €
€€ € € € @€€ @@ ÿ€ €@ ÿ @ @€ ÿÿÿ ÀÀÀ ÿ ÿÿ ÿ ÿÿ ÿ ÿ ÿ €ÿÿ
€ÿ ÿÿ€ ÿ€€ € ÿ @€ÿ W F dP ™ p„1 ‚„ßS G Ü Í
/¬„7‚„ßS G WG ªö[ ªÃªö[ ,OÖ÷¿7[ ¼ô[
? D÷¿ 4~^ G ðô[ ]· G ªö[ ªö[ „õ[ ù·G
ªö[ àõ[ ø€ºjö[ ªÃ�º ¨
»4~^ ¬õ[ RI¸ÿÿÿÿ¸õ[ Í·F jö[ F *ö[ $�º ¨
»4~^ ìõ[ RI¸ÿÿÿÿøõ[ Í·G ªö[ G jö[ Xõ[ ö[ ¸K¸ÿÿÿÿøõ[
&·4~^ < á €º ˜õ[ Tö[ ¸K¸ÿÿÿÿ8ö[ &·4~^
G
__END__
now, what i am trying to do is save contents of a binary file
in c, using the djgpp gcc compiler and compile the file
right in with my c program so i can read from it
and use its contents...
kind of like zip2exe, except with the ability
to write the file where i want and do other things
besides just unzip a zipfile--
in other words write more code around it-
not just do one thing (save a file).
and i'd like to do it without having to
store it into an array (would be a problem with say, a .iso
cd image - or other large files, etc.)
and i don't have a clue how to do it.
comp.lang.c told me to come here and ask
since it's beyond the core c language.
- Raw text -