Convert from pascal to c++

Var s:string;
Begin
write('Enter a string: ');readln(s);
While (Pos('(',s)>0)and((Pos(')',s)>0)) do
Delete(s,Pos('(',s),Pos(')',s)-Pos('(',s)+1);
writeln('Result = ',s);
readln;
End.
Why?
my pascal is decades rusty.
as far as I can tell you want to replace all instances of () symbols in a string. Is that correct?

you can follow the second piece of this example on using replace_if with strings:
https://www.geeksforgeeks.org/stdstringreplace-stdstringreplace_if-c/

use getline(cin, s); for readline
everything else is in that example.
Last edited on
thank you
Topic archived. No new replies allowed.