私は主メモリ上で動作するテキストエディタを作成しています。私はファイル操作を使用することは許可されていませんが、私は文字列クラスライブラリまたはcstringライブラリを使用することは許可されていません。 今私が達成しなければならないのは、1行に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;
}
私はあなたのためにそのコードを書いていません。それを自分で試してみてください。遭遇した特定の問題について助けてくれるかもしれません。 –
実際に私はどのライブラリと関数がこれを達成することができるかを知りたいと思います。cin.getlineはこれを実現します –
あなたはこれらのどれも使用しないように制限されていますか?私はあなたが望むものを得られません。 –