473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to multiply a string or repeat it

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
3 30337
RedSon
5,000 Expert 4TB
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
9,208 Expert Mod 8TB
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
dynamo
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

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

Similar topics

1
by: Oliver Walczak | last post by:
This seems to be a quite difficult approach. Try this: ##################################################################### import traceback class MyTraceback: def __init__(self):...
12
by: Kamilche | last post by:
I was looking for a way to speed up detecting invalid characters in my TCP string, and thought of yet another use for the translate function! If you were to 'translate out' the bad characters, and...
5
by: Wade G. Pemberton | last post by:
Can't find it quickly in the reference books.
11
by: vips | last post by:
I have a string str="10*12*14" now I want the total of this value i.e. 10 multiply 12 multiply 14 how do i get it ? is there any function in vb.net to do that ?? if i put it as query to...
8
by: Csaba Gabor | last post by:
I wrote a .repeat(n) function for strings which seemed to work fine: String.prototype.repeat = function(n) { // repeats the string n times if (n<1) return ""; if (n<2) return this; for (var...
0
by: komandjaja | last post by:
Hi everybody. I am new here and I don't know much about CSS. However, I have a blog at multiply http://komandjaja.multiply.com and I have customized the CSS codes there to make a new theme. When I...
3
by: Morgz123 | last post by:
Okay Well i'm kinda new here First Post xD Well i recently entered in an online programming contest and i has since finished the question i went extremly badly on was when they wanted a program...
1
by: Gavin Chen | last post by:
Hello: I tried to install Tk800.015 on SunOS 4.1.4 with perl 5.6.2. At "make test" time, I got the error message as below: collect2: ld returned 2 exit status ld:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.