home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_06
/
8n06076a
< prev
next >
Wrap
Text File
|
1990-05-01
|
967b
|
47 lines
Listing 8:
#include <stdio.h>
#define MS_DOS_EOF 26
#define MS_DOS_CR 13
main(argc, argv)
/* Translate MS-DOS text file to UNIX file */
/**** Does not check for errors *****/
/* Usage translate file-in file-out */
int argc;
char *argv[];
{
int c;
FILE *file_in, file_out;
file_in = fopen(argv[1],"rb");
file_out = fopen(argv[2],"wb");
while (1)
{
c = fgetc(file_in);
switch(c)
{
case EOF:
case MS_DOS_EOF:
/* All done */
goto end;
break;
case MS_DOS_CR:
/* Ignore the CR value */
break;
default:
fputc(c, file_out);
break;
}
}
end:
fclose(file_in);
fclose(file_out);
exit(0);
}