I’m building a simple interpreter of a language that i’m developing, but how i can do a cout of something that is after a word and in rounded by “”, like this:
#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;
}
And how i can remove the “” when printing the text. Here is the file example:
print “Hello, World”
Read my post in the middle of the answers!
Thanks
I’m assuming what you want is to identify quoted strings in the file, and print them without the quotes. If so, the below snippet should do the trick.
This goes in your
while(!file.eof())loop: