By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,515 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,515 IT Pros & Developers. It's quick & easy.

how to multiply a string or repeat it

P: 51
I have an assignment to repeat a string in a pattern.I can do this in python easily since we are allowed to repeat strings however.The same is not the case in c++.How would i do this in c++?Any suggestion appreciated.
May 31 '07 #1
Share this Question
Share on Google+
3 Replies


RedSon
Expert 5K+
P: 5,000
I have an assignment to repeat a string in a pattern.I can do this in python easily since we are allowed to repeat strings however.The same is not the case in c++.How would i do this in c++?Any suggestion appreciated.
You can repeat strings, its called copying or looping, or outputting in a loop or various other things. Manipulating strings to repeat a pattern is not something that *only* python can do.
May 31 '07 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Maybe:

Expand|Select|Wrap|Line Numbers
  1. string str;
  2. for(int i = 0; i < 10; ++i)
  3. {
  4. str += "Hello";
  5. }
  6.  
May 31 '07 #3

P: 51
Maybe:

Expand|Select|Wrap|Line Numbers
  1. string str;
  2. for(int i = 0; i < 10; ++i)
  3. {
  4. str += "Hello";
  5. }
  6.  
Thanks for taking the time.
Jun 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.