📄 zzzzz.cpp
字号:
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
FILE *fp,*fp1,*fp2,*fp3,*fp4,*fp5,*flp;
char ch,t;
char cch[50];
int k,m;
//char get()
//{
//int t;
//t=fgetc(fp);
//if(t=='\n'||t=='\t'||t=='\r') t=' ';
//return t;
//}
int SearchKey(char *cch )
{
char *StrToken[32]={"auto","break","case","char","const",
"continue","default","do","double","else","enum","extern",
"float","for","goto","if","int","long","register","return",
"short","signed","sizeof","static","struct","switch",
"typedef","union","unsigned","void","volatile","while"};
for(int i=0;i<32;i++)
{
if(strcmp(StrToken[i],cch)==0)
return i;
}
return 0;
}
void nextget()
{
//char *word;
//int result;
ch=getc(fp);
while(ch==' '||ch=='\t'||ch=='\n'||ch=='\r')
{
ch=getc(fp);
}
//if(ch=='\n')
//return;
if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||(ch=='_'))
{
while((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||(ch>='0'&&ch<='9')||(ch=='_'))
{
cch[k]=ch;
k=k+1;
ch=getc(fp);
}
if(SearchKey(cch)==0)
{
fprintf(fp1,"%s\n",cch);
fseek(fp,-1L,SEEK_CUR);
}
else
{
fprintf(fp2,"%s\n",cch);
fseek(fp,-1L,SEEK_CUR);
}
return;
}
else if(ch>='0'&&ch<='9')
{
while(ch>='0'&&ch<='9')
{
cch[k]=ch;
k=k+1;
ch=getc(fp);
}
fprintf(fp3,"%s\n",cch);
fseek(fp,-1L,SEEK_CUR);
return;
}
else if(ch=='+'||ch=='-'||ch=='*'||ch=='/')
{
cch[k]=ch;
//k=k+1;
ch=getc(fp);
if(ch!=EOF)
{
//cch[k]=ch;
if(cch[k]==ch)
{
k=k+1;
cch[k]=ch;
fprintf(fp4,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
if(ch=='=')
{
k=k+1;
cch[k]=ch;
fprintf(fp4,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||(ch=='_')||(ch>='0'&&ch<='9'))
{
fprintf(fp4,"%s\n",cch);
fseek(fp,-1L,SEEK_CUR);
return;
}
k=k+1;
cch[k]=ch;
fprintf(fp5,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
}
else if(ch=='('||ch==')'||ch=='['||ch==']'||ch=='{'||ch=='}')
{
fprintf(fp4,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
else if(ch=='|'||ch=='!'||ch=='<'||ch=='>'||ch=='='||ch=='\'')
{
cch[k]=ch;
//k=k+1;
ch=getc(fp);
if(ch!=EOF)
{
//cch[k]=ch;
if(ch==cch[k])
{
k=k+1;
cch[k]=ch;
fprintf(fp4,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')||(ch=='_')||(ch>='0'&&ch<='9'))
{
fprintf(fp4,"%s\n",cch);
fseek(fp,-1L,SEEK_CUR);
return;
}
k=k+1;
cch[k]=ch;
fprintf(fp5,"%s\n",cch);
//fseek(fp,-1L,SEEK_CUR);
return;
}
}
}
void main()
{
fp1=fopen("b.txt","w");
fp2=fopen("g.txt","w");
fp3=fopen("s.txt","w");
fp4=fopen("f.txt","w");
fp5=fopen("c.txt","w");
char name[30];
printf("请输入文件名:");
scanf("%s",name);
fp=fopen(name,"r");
//ch=fgetc(fp);
if (fp==0)
{
printf("文件为空!");
return;
}
//fp=fopen(name,"w");
while (ch!=EOF)
{
k=0;
nextget();
memset(cch,0,50);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -