[ale] dos2unix
Chris Fowler
cfowler at outpostsentinel.com
Fri Apr 12 16:25:03 EDT 2002
Someone asked for this. Here it is..
gcc -o dos2unix dos2unix.c
#include <stdio.h>
#include <string.h>
int
main(int argc, char *argv[])
{
FILE *fp;
char line[128];
char *ptr;
if(argc != 2)
{
fprintf(stderr, "dos2unix <filename>");
exit(1);
}
if((fp = fopen(argv[1], "r")) == NULL)
{
perror("open source");
exit(1);
}
while(!feof(fp))
{
fgets(line, sizeof(line), fp);
if(feof(fp))
break;
ptr = strrchr(line, '\r');
if(ptr)
{
*ptr = '\n';
ptr++;
*ptr = 0;
}
fputs(line, stdout);
}
close(fp);
return 0;
}
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list