Mar 5, 2015 at 12:53pm UTC
Hello, I need a help. A want to create method to print the text. Also, i want to create new simple command say(); to print the text. How can i do that please?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
string command;
string textToPrint;
main:
std::cout <<"> " ;
std::cin >> command;
if (command=="say(" +textToPrint+");" ) {
std::cout<< textToPrint << endl;
}
system("echo." );
goto main;
return 0;
}
Last edited on Mar 5, 2015 at 12:55pm UTC
Mar 5, 2015 at 5:53pm UTC
Instead of cin >> command
, you should include string and use getline(cin, command)
To check the command, you should just check to see if it has say. Your if will almost never pass if you check it the way you do.