Sally

Hello I came in September 2020 for a language (Sally : https://www.cplusplus.com/forum/beginner/272924/2/ ) interpreter that I am trying to modify, you had helped me to retrieve all the numbers from the source file including the comma numbers.I would like to know how to add a character string to the stack :
1
2
Sptr->params.push(Token(DOUBLE, -p.m_value, "")); //works here for numerical value


but if I try with text it doesn't work, can you explain to me what's wrong?

1
2
3
4
5
6
7
  void Sally::doInputString(Sally *Sptr)
{
	
        string newString; //it is equivalent to p.m_text ?
	cin >> newString;
	Sptr->params.push(Token(STRING, newString, ""));
}
if your code is based off c-style strings, use newstring.cstr() to see if that works?
Thank you, I figured out how to do it:
1
2
3
4
5
6
7
  void Sally::doInputString(Sally *Sptr)
{
	
    string newString; //it is equivalent to p.m_text ?
	cin >> newString;
	Sptr->params.push(Token(UNKNOWN, 0.0, newString));	
}
Topic archived. No new replies allowed.