First, please don't top post, and please do read up on that now.
Some people here, e.g. Victor, will simply ignore you when you do that.
Others, such as I, take it as an indication of the total newbie or troll.
I'm giving you the benefit of assuming that you're a total newbie, even though I do vaguely recall a "vlad" troll here some years ago, and even thoughfantasy statements, fallacies, and incoherence (exhibited below, first quote) are very strongly indicative of trolling (sorry for mentioning this, but necessary).
So,
---
It would be musch better if you would edd bla...bla..bla..
Sorry, that's incoherent, it reads like gobbledegook to me.
and learn what is array in C/C++.
I'm sorry, but there is no such language as "C/C++".
Notwithstanding the misleading title of a Microsoft book.
In particular, much modern C code is not valid as C++ code, some C code does compile as C++ but means something different in C++, and some best practices (e.g. whether to cast the result of malloc, if one uses malloc) are diametrically opposite, or differ, between the languages.
It's therefore best to not start out by conflating the languages.
Especially for a newbie.
ALso you should read the original post where is is clear enough said what
type of data orhanization have to be used in the assignment.
It's true that the type of data organization used by the OP is clear, namely an array.
There is no conflict between that and my simple suggestion of using std::string and its concatenation operation.
The answer may not, however, apply to all possible choices of item data. But the OP did not ask for that. The OP asked for "any suggestions" and got one, which happens to be much simpler than the answers so far, including yours.
Since I must assume that you are a newbie, as indicated by your top-posting, and as indicated by your ignorance of what arrays are, and more,
* the OP is most likely dealing with strings or data easily represented as strings,
* std::string provides constant time indexing, so it's a logical array, andit has a guaranteed contiguous buffer, so it's also an array by memory layout criterions (however misguided it would be to apply such criterions here), and
* in the cases where the provided solution fits it's very simple and clear and does the job, contrary to your opinion that it's irrelevant.
Moreover your example has totally different symantic because it does not
shift a sequane but add a new element at the its beginning.
Shifting to the right always adds a new element to the beginning.
If you don't introduce a new element then you're moving around the rightmost element, in which case it's called "rotating" rather than "shifting".
So the size of the resulting sequence differs from the original sequence.
Yes, the OP neglected to state anything about the size, so I did not add code to trim down the size.
If such code were added (it's trivial and very short, E.G. a call to .resize()) then one could equally well argue that it should not be there, depending on what one thinks is most likely the unstated requirement. For example,in arbitrary precision arithmetic, "bignum" arithmetic, shifting (to the left) does extend the sequence. The OP has not clarified what he/she wants.
I do not now and have never viewed comp.lang.c++ as a question-and-answer forum: while comp.lang.c++ does not have a charter, it's traditionally a discussion and learning forum, which is a very different kind of beast than Q&A. Newbie Q&A is best done in alt.comp.lang.learn.c-c++ or other groups dedicated to that sort of thing. Which is not to say that this group is not inclusive -- it is! -- but what kinds of answers can be considered appropriate or inappropriate or incomplete, is very different.
Anyway, in the absence of a specification it's best to not needlessly assume, and not needlessly add complicating details -- the OP can do that.
Cheers, and hope this helps!
;
- Alf