I am trying to write a program which is a game of executioner.
#include & lt; Iostream & gt; #include & lt; String & gt; #include "assn.h" using namespace std; Int main () {clearScreen (); Cout & lt; & Lt; "Enter words or phrases:"; String phrase; Std :: getline (std :: cin, phrase); Cout & lt; & Lt; Andal & lt; & Lt; "Your phrase:" & lt; & Lt; Phrase & lt; & Lt; Endl; Cout & lt; & Lt; Endl; }
Currently I can get the input string and get the empty space, but I want to create another string where all the letters have been replaced with hyphens and Spaces are preserved. I have tried to see it and how it can not be ascertained.
Here one is for example algorithm
replace_if
#include & lt; Iostream & gt; #include & lt; String & gt; # Include & lt; Algorithm & gt; Int main () {namespace std; String input {"This is an exam"}; String censored {input}; Replacement_if (censored. Bg (), censored.ed (), :: iislifa, '-'); Cout & lt; & Lt; Sensor & lt; & Lt; Std :: endl; }
Output:
---- - - ----
call above Replace_if
replaces the ones with a dashed to iterative on a container (in this case, a string of characters) and alphabetically, leaving the blank space.
No comments:
Post a Comment