delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/24/17:45:36

Message-ID: <39A5527A.4FD240A5@home.com>
From: yhvhboy1 <yhvhboy1 AT home DOT com>
X-Mailer: Mozilla 4.7 [en] (Win98; U)
X-Accept-Language: en,el
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: __DATA__ in c
References: <wzjn5.7894$ZI2 DOT 334216 AT news1 DOT rdc1 DOT il DOT home DOT com> <834s4emb0i DOT fsf AT mercury DOT bitbucket>
Lines: 52
Date: Thu, 24 Aug 2000 16:46:38 GMT
NNTP-Posting-Host: 24.15.107.158
X-Complaints-To: abuse AT home DOT net
X-Trace: news1.rdc1.il.home.com 967135598 24.15.107.158 (Thu, 24 Aug 2000 09:46:38 PDT)
NNTP-Posting-Date: Thu, 24 Aug 2000 09:46:38 PDT
Organization: @Home Network
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2026   by DJ Delorie     Updated Sep 20 2026