I have this part of code:
char statement[255];
string result = ""; //or you can use result[299] too
cin.getline(statement,255);
/*
I don't know the code to be inserted here
*/
cout<<statement<<endl;
/*or cout<<result<<endl;*/
now, what I want to do is this:
if user inputted x = x + y * z - a / b ;, I want the output to be
x = ((((( x ) + y ) * z ) - a ) / b) ;
how can I insert those parentheses into the original input? thanks. by the way, I really need to store it in a new array or a string. I just don't know how to insert those parentheses.
std::stringhas an insert method en.cppreference.com/w/cpp/string/basic_string/insert