+ 1
Is there a C++ Equivalent of this Python3 Function?
Is there a C++ Equivalent of this Python3 Function? def times_n(string, n): temp = "" for everychar in string: temp += everychar*n #this part return temp If I tried to do something like that in C++, it will just multiply the ASCII value by n and adding it into temp. So, how can I do that in C++? Thanks in advance!
2 odpowiedzi
+ 5
You can create a string of a multiplied char with a specific constructor:
string(5, '*');
will produce *****.
+ 2
Thanks for the answer!!