📄 filter.cpp
字号:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <string.h>
#include <iomanip.h>
void main()
{ char filename[10];
void dealString(char ss[]);
cout << "输入文件名:";
cin >> filename;
ifstream ifile(filename, ios::in|ios::nocreate);
ofstream ofile("result.cpp");
if(! ifile) {
cout << "文件不存在" << endl;
exit(0);
}
if(! ofile) {
cout << "Result.cpp 文件不能建立!" << endl;
exit(0);
}
char str[80];
int cn = 1;
while(! ifile.eof()) {
ifile.getline(str, 80);
dealString(str);
ofile << setw(8) << cn << ":" << str << endl;
cn ++;
}
cout << "转换成功:Result.cpp 文件已经建立!" << endl;
ifile.close();
ofile.close();
}
void dealString(char ss[])
{ int slen = strlen(ss), i;
for(i = 0; i < slen; i ++) {
if(ss[i] == '/' && ss[i+1] == '/') {
ss[i] = '\0';
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -