我在做一个赋值,其中我正在创建一个处理主内存的文本编辑器。我不允许使用文件处理,我也不允许使用字符串类的字符串库或cstring库。 现在我必须实现的是,一行只包含60个字符,如果用户超过60个字符的输入,它应该自动转移到下一行,我也必须显示行号,而用户正在给输入 我的代码是在这里如果用户超过特定字符数,则更改行
#include <iostream>
using namespace std;
int main()
{
char***files=new char**[50];
char**fileNames=new char*[50];
int fileCount=0;
while (true)
{
int selector=0;
cout<<"MacMAds Notepad"<<endl<<endl;
cout<<"Press 1. To Create a new file"<<endl;
cout<<"Press 2. To View an existing file by giving file name"<<endl;
cout<<"Press 3. To edit an existing file by giving its name"<<endl;
cout<<"Press 4. To copy an existing file to a new file"<<endl;
cout<<"Press 5. To delete an existing file by giving its name"<<endl;
cout<<"Press 6. To view listof all files with the names"<<endl;
cout<<"Press7. To Exit"
cin>>selector;
if (selector==7)
break;
if (selector==1)
{
cout<<"Please enter the name of file: ";
cin>>fileNames[fileCount];
int nLines=0;
cout<<"Please enter the number of lines for "<<fileNames[fileCount]<<": ";
cin>>nLines;
files[fileCount]=new char*[nLines];
for (int i=0;i<nLines;i++)
{
files[fileCount][i]=new char[61];
cin.getline(files[fileCount][i],60)
}
}
}
return 0;
}
我们不会为您编写该代码。自己尝试一下,我们可能会为您遇到的具体问题提供帮助。 –
其实我想知道哪些库和函数可以实现这一点,因为我dnt的cin.getline将实现这个 –
你被限制不使用任何这些?那么我没有得到你想要的东西。 –