int dos2unix(char * filename)
{
FILE *target;
FILE *tmpfd;
int ch;
target = fopen(filename, "r+");
if(NULL == target)
{
return -1;
}
tmpfd = tmpfile();
if(NULL == tmpfd)
{
fclose(target);
return -1;
}
while((ch = fgetc(target)) != EOF)
{
if('\r' == ch)
{
continue;
}
fputc(ch, tmpfd);
}
rewind(tmpfd);
rewind(target);
cpfile(tmpfd, target);
fclose(target);
return 0;
}
dos2unix命令的c实现
最新推荐文章于 2024-04-07 21:37:17 发布