| 查看: 587 | 回复: 2 | ||
| 当前主题已经存档。 | ||
[资源]
Windows格式的文件转成Unix格式的文件
|
||
|
Windows格式的文件转成Unix格式的文件 /* win2unix */ #include "stdio.h" #include "stdlib.h" #include "conio.h" #include "string.h" int main(int argv, char * args[]){ FILE *fp1,*fp2; char c; char s[100]; if(argv<2){ printf("Usage: win2unix input-file-name [output-file-name]" ;return 1; } if((fp1=fopen(args[1],"rb" )==NULL){printf("Error: Fail to open %s.",args[1]); return 1; } if(argv==2){ sprintf(s,"u_%s",args[1]); } else{ sprintf(s,"%s",args[2]); if(strcmp(s,args[1])==0){ printf("Error: Output file name must not be same to that of the input file." ;fclose(fp1); return 1; } } fp2=fopen(s,"wb" ;while(1){ c=fgetc(fp1); if(feof(fp1)!=0){ break; } if(c!='\r'){ fputc(c,fp2); } } fclose(fp1); fclose(fp2); return 0; } 附:如果在Unix下,只消几行语句就可以解决问题: #!/bin/sh tr -d '\015' < "$1" >temp.$$ mv temp.$$ "$1" |
» 猜你喜欢
2026年第四届电动车与车辆工程国际会议(CEVVE 2026)
已经有0人回复
德国亥姆霍兹Hereon中心招收两位医用镁合金腐蚀与LPSO相变方向2026公派博士生
已经有0人回复
物理学I论文润色/翻译怎么收费?
已经有194人回复
推荐一款可以AI辅助写作的Latex编辑器SmartLatexEditor,超级好用,推荐试试
已经有10人回复
2026-CJ开始申报了
已经有1人回复
2楼2008-01-08 13:37:50
3楼2008-01-08 15:32:36













;
回复此楼