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 p1 S G
/7S G WG [ ê[ ,O7[ [
? D 4~^ G [ ] G [ [ [ G
[ [ j[
4~^ [ RI[ F j[ F *[ $
4~^ [ RI[ G [ G j[ X[ [ K[
&4~^ < [ T[ K8[ &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 -