Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!samsung!uunet!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: mailing binary files Message-ID: <16968@crdgw1.crd.ge.com> Date: 20 Feb 91 21:55:31 GMT References: <1025@tfsg.UUCP> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Lines: 40 In article <1025@tfsg.UUCP>, mark@tfsg.UUCP (Mark Crafts) writes: |>Quick question: |> |>What's the best way to send binary files through E-mail (you know, with |>a "---cut here---" line) so that when "cut there", it can be saved to |>a file and executed (or unpacked then executed or whatever). Well, C doesn't have any built-in "mail binary file" operator, so we'll have to fudge it. It would probably be easier to use "system()" to invoke mail, although using "popen()" might be more efficient. #include int main() { FILE *binfile,*textfile; int c; binfile=fopen("fname.bin","r"); textfile=fopen("fname.txt","w"); fprintf(textfile,"---cut here---\n"); while ((c=getc(binfile))!=EOF) { fprintf(textfile,"%#X ",c); } fclose(textfile); fclose(binfile); system("mail user@domain < fname.txt"); } |> |> Mark |> |>Please E-Mail, thanks I would have, but seeing how this is just so applicable to comp.lang.c, I thought I'd post it. ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com