int syn=-1;//syn即为种别码,约定‘$’的种别码为0,为整个源程序的结束符号一旦扫描到这个字符代表扫描结束
int pProject = 0;//源程序指针,始终指向当前源程序待扫描位置。
FILE *fp;
if((fp=fopen("E:\\2018.txt","r"))==NULL)
{
cout<<"cam not open";
exit(0);
}
resourceProject[pProject]=fgetc(fp);
while(resourceProject[pProject]!='$')
{
pProject++;
resourceProject[pProject]=fgetc(fp);
}
resourceProject[++pProject]='\0';
fclose(fp);
cout<<endl<<"源程序为"<<endl;
cout<<resourceProject<<endl;
//过滤
filterResource(resourceProject, pProject);
cout<<endl<<"过滤之后"<<endl;
cout<<resourceProject<<endl;
pProject=0;
while(syn!=0)
{
Scanner(syn,resourceProject,token,pProject);
}
return 0;
}
四、程序运行结果:(截屏)