Question:
resize in c++ programming?
gsr
2008-09-21 21:53:44 UTC
I am working on a small project in C++ and have these following question on resize.

For resize(n, char c) if n is greater than the current length, it is expanded by adding as many as instances of c.
If i want to add in a unique set of char c how will i be able to do it. Eg
a=A B C
a.resize(5, 'x')
output A B C x x

Now if i want to resize a such that my output is A B C F 0 how will be be able to do it since we cant do a. resize(5, ('F','0')).

Any help or suggestion is appreciated...thanks
Three answers:
Ahmed The Ninja
2008-09-21 22:39:43 UTC
I will have to agree with the first poster.
2008-09-21 22:05:44 UTC
wouldn't you be able to do ?



a.resize( 4, 'F' );

a.resize( 5, '0' );



perhaps you can write your own resize function by passing the set of characters as parameters and iterating through them as you call the resize function.
2016-11-30 03:12:10 UTC
bypass on your lectures and pay interest. examine your lecture notes and attempt issues out. communicate on your tutors and lab assistants, or perhaps your lecturer in case you could. examine your textbooks. Asking right here won't allow you to while it gets to examination time.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...