cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Convert from pascal to c++
Convert from pascal to c++
Jul 12, 2020 at 1:30pm UTC
trut8
(2)
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.
Jul 12, 2020 at 2:13pm UTC
dutch
(2548)
Why?
Jul 12, 2020 at 3:01pm UTC
jonnin
(11437)
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
Jul 12, 2020 at 3:05pm UTC
Jul 12, 2020 at 3:07pm UTC
trut8
(2)
thank you
Topic archived. No new replies allowed.