编译第一步:去源代码(C)注释
2011-03-04 16:50
211 查看
#include
#include
main()
{
char ch1,ch2,ch3,ch4;
FILE *fp1,*fp2;
if((fp1=fopen("D://c programs//常见题//input.txt","r"))==NULL)
{
printf("cann't open the input file/n");
exit(1);
}
if((fp2=fopen("D://c programs//常见题//output.txt","w"))==NULL)
{
printf("cann't open the output file/n");
exit(1);
}
ch1=fgetc(fp1);
ch2=fgetc(fp1);
while(!feof(fp1))
{
if('/'==ch1 && '/'==ch2)
//这里注意,判断条件要细分好,在设及到条件分支语句时,
//要注意,每个分支都要单独的测试到,会更容易维护
{
ch3=fgetc(fp1);
while(!feof(fp1))
{
if(10==ch3)
{
fputc(ch3,fp2);
break;
}
else
{
ch3=fgetc(fp1);
}
}
ch1=fgetc(fp1);
ch2=fgetc(fp1);
}
if('/'==ch1 && '*'==ch2)
{
ch3=fgetc(fp1);
ch4=fgetc(fp1);
while(!feof(fp1))
{
if('*'==ch3 && '/'==ch4)
{
ch1=fgetc(fp1);
ch2=fgetc(fp1);
break;
}
else
{
ch3=ch4;
ch4=fgetc(fp1);
}
}
}
else
{
fputc(ch1,fp2);
ch1=ch2;
ch2=fgetc(fp1);
}
}
fputc(ch1,fp2);
fclose(fp1);
fclose(fp2);
return 1;
}
#include
main()
{
char ch1,ch2,ch3,ch4;
FILE *fp1,*fp2;
if((fp1=fopen("D://c programs//常见题//input.txt","r"))==NULL)
{
printf("cann't open the input file/n");
exit(1);
}
if((fp2=fopen("D://c programs//常见题//output.txt","w"))==NULL)
{
printf("cann't open the output file/n");
exit(1);
}
ch1=fgetc(fp1);
ch2=fgetc(fp1);
while(!feof(fp1))
{
if('/'==ch1 && '/'==ch2)
//这里注意,判断条件要细分好,在设及到条件分支语句时,
//要注意,每个分支都要单独的测试到,会更容易维护
{
ch3=fgetc(fp1);
while(!feof(fp1))
{
if(10==ch3)
{
fputc(ch3,fp2);
break;
}
else
{
ch3=fgetc(fp1);
}
}
ch1=fgetc(fp1);
ch2=fgetc(fp1);
}
if('/'==ch1 && '*'==ch2)
{
ch3=fgetc(fp1);
ch4=fgetc(fp1);
while(!feof(fp1))
{
if('*'==ch3 && '/'==ch4)
{
ch1=fgetc(fp1);
ch2=fgetc(fp1);
break;
}
else
{
ch3=ch4;
ch4=fgetc(fp1);
}
}
}
else
{
fputc(ch1,fp2);
ch1=ch2;
ch2=fgetc(fp1);
}
}
fputc(ch1,fp2);
fclose(fp1);
fclose(fp2);
return 1;
}
相关文章推荐
- emule源代码研究,第一步,DEBUG模式编译!
- Qt Creator 源代码(UTF-8)中如果有中文注释,会编译报错
- emule源代码研究,第一步,DEBUG模式编译!
- 在Ubuntu上下载、编译和安装Android最新源代码
- 在Ubuntu上下载、编译和安装Android最新源代码
- 在Ubuntu上下载、编译和安装Android最新内核源代码(Linux Kernel)
- 让你团队里所有人在编译工程时都要看你的代码注释
- opencv在vs2012下重编译详细教程——解决按f11进入不了源代码
- RedHat Linux 下安装MPlayer 编译源代码方式
- 在Ubuntu上下载、编译和安装Android最新源代码
- windows下编译ffmpeg源代码
- 反编译Apk,Dex,Jar,查看java源代码
- 在windows下使用vs2013编译和调试mysql源代码
- Centos通过源代码编译安装httpd并启动
- 完整的android开发环境搭建和源代码编译过程 .
- 将C语言源代码编译成动态链接库
- mysql-connector-net 源代码中有编码导至编译不通过的解决办法
- 解决VS编译提示“当前不会命中断点,源代码与原始版本不同”的问题
- 在Ubuntu上下载、编译和安装Android 4.2 最新内核源代码(Linux Kernel)
- 【组件】devExpress源代码编译错误