mailing binary files
Christopher R Volpe
volpe at camelback.crd.ge.com
Thu Feb 21 08:55:31 AEST 1991
In article <1025 at tfsg.UUCP>, mark at 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 <stdio.h>
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 at 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 at crd.ge.com
More information about the Comp.lang.c
mailing list