📄 scaner.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -