📄 wordreset.cpp
字号:
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
FILE *fpr;
FILE *fpw;
char astr[100]="struct";
char bstr[100]="class";
char lexstr[100];
int i=0;
while(1)
{
printf("now input two words, with the 2th inplace of the 1s:\n");
scanf("%s %s",astr,bstr);
if(astr[0]=='0' && bstr[0]=='0')
return 0;
fpr=fopen("code.txt","r");
fpw=fopen("out.txt","w");
ch=fgetc(fpr);
while(ch!=EOF)
{
if(isalpha((int)ch))
{
int k=0;
while(isalnum((int)ch))
{
lexstr[k]=ch;
ch=fgetc(fpr);
k++;
}
lexstr[k]='\0';
int val;
val=strcmp(astr,lexstr);
if(val==0)
{
fprintf(fpw,"%s",bstr);
int static i=0;
//scanf("%d",&i);
if((!strcmp(astr,"struct")) && (!strcmp(bstr,"class")))
{
i++;
while(ch!='{')
{
fputc(ch,fpw);
ch=fgetc(fpr);
if(ch=='{'||ch=='}'||ch==';')
break;
}
if(ch=='{')
{
fputc(ch,fpw);
fprintf(fpw,"\npublic:");
ch=fgetc(fpr);
}
}
}
else
fprintf(fpw,"%s",lexstr);
}
if(ch==EOF)
break;
fputc(ch,fpw);
ch=fgetc(fpr);
}
fclose(fpr);
fclose(fpw);
//
fpr=fopen("out.txt","r");
fpw=fopen("code.txt","w");
ch = fgetc(fpr);
while(ch!=EOF)
{
//fprintf(fpw,"%c",ch);(int)
fputc((int)ch,fpw);
ch = fgetc(fpr);
}
fclose(fpr);
fclose(fpw);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -