私は自分が開発している言語の簡単なインタプリタを作成していますが、次のように、単語の後に「」で囲まれたもののcoutを実行するにはどうすればよいですか。
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main( int argc, char* argv[] )
{
if(argc != 2)
{
cout << "Error syntax is incorrect!\nSyntax: " << argv[ 0 ] << " <file>\n";
return 0;
}
ifstream file(argv[ 1 ]);
if (!file.good()) {
cout << "File " << argv[1] << " does not exist.\n";
return 0;
}
string linha;
while(!file.eof())
{
getline(file, linha);
if(linha == "print")
{
cout << text after print;
}
}
return 0;
}
また、テキストを印刷するときに「」を削除するにはどうすればよいですか。ファイルの例を次に示します。
印刷「Hello、World」
答えの真ん中で私の投稿を読んでください!
ありがとう