我在C++ [非gui]中创建了一个文本编辑器,到目前为止我已经结束了这个代码.. 我得到两个未声明的错误...为什么?在C++中创建文本编辑器而不使用任何图形库[功能未声明的错误]
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int op;
cout<<"do you want to open example.txt or overwrite?\nIf you want to overwrite enter 1 , if you want to view it enter 2. :\n";
cin>>op;
if(op==1)
{
edit();
}
else if(op==2)
{
open();
}
}
void edit()
{
int op;
string x;
ofstream a_file("example.txt" , ios::app);
cout<<"HEY ENTER SOME TEXT TO BE WRITTEN TO EXAMPLE.txt [created by rohan bojja]\n--------------------------------------------------------------------------------\n";
getline (cin , x);
a_file<<x;
cout<<"want to type in an other line?\n1 for YES, 2 for NO";
cin>>op;
while(op==1)
{
a_file<<"\n";
edit;
}
cout<<"Do you want to quit?\n1 for YES , 2 for NO";
cin>>op;
if (op==2)
{
edit;
}
}
void open()
{
int op;
ifstream a_file("example.txt");
cout<<"You are now viewing example.txt [created by rohan bojja]\n--------------------------------------------------------------------------------\n";
cout<<a_file;
cout<<"Do you want to quit?\n1 for YES , 2 for NO";
cin>>op;
if(op==2)
{
open;
}
}
但是,在编译时出现错误[代码块生成日志]:
F:\Projects\c++\TextEditor\texteditor.cpp: In function 'int main()':
F:\Projects\c++\TextEditor\texteditor.cpp:14: error: 'edit' was not declared in this scope
F:\Projects\c++\TextEditor\texteditor.cpp:18: error: 'open' was not declared in this scope
这意味着要么1)或2) - 你不需要这两个。 – TonyK
谢谢,我编辑它使其更加清晰。 – bstamour
用你的''''和我''或',我们完成了这件事:-) – TonyK