我正在为我正在开发的一种语言构建一个简单的解释器,但是我如何才能对一个单词之后并用“”四舍五入的东西做一个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;
}
以及如何在打印文本时删除“”。这是文件示例:
打印“你好,世界”
在答案中间阅读我的帖子!
谢谢