scaner.cpp
来自「扫描器程序」· C++ 代码 · 共 76 行
CPP
76 行
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <stdlib.h>
int main()
{
FILE *fp1,*fp2;
if ((fp1=fopen("scaner.cpp","r"))==NULL)
{
cout<<"Cannot open the file source.txt!"<<endl;
exit(1);
}
if ((fp2=fopen("result.txt","w"))==NULL)
{
cout<<"Cannot open the file result.txt!"<<endl;
exit(1);
}
char ch,temp;
while(ch!=EOF){
switch(ch)
{
case' ' :
case'\n':
case'\t':
ch=fgetc(fp1);
break;
case'/':
temp=ch;
ch=fgetc(fp1);
if (ch=='/')
{
ch=fgetc(fp1);
while(ch!='\n'&&ch!=EOF)
ch=fgetc(fp1);
if (ch==EOF)
exit(0);
}
else if (ch=='*')
{
ch=fgetc(fp1);
while (1)
{
if (ch==EOF)
{
cout<<"error\n";
exit(1);
}
while(ch!='*')
{
ch=fgetc(fp1);
break;
}
}
}
else
{
fputc(ch,fp2);
cout<<ch;
}
break;
default:
cout<<ch;
fputc(ch,fp2);
ch=fgetc(fp1);
fclose(fp2);
}
}
system("pause");
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?