Hello, folks. The main objective I am trying to accomplish is taking in a user string and saving the reverse to it. I also must take in an 'x' amount of strings from the user.
Example:
1 2 3 4 5 6 7 8 9 10
|
How many strings do you want to create?: 2
Enter the strings:
ABCDE
FGHIJK
The reverse of the strings you entered is:
EDCBA
KJIHGF
|
And obviously if they were to put 6 for the amount of strings then it would go like:
ABC
DEF
GHI
JKL
MNO
PQR
and return the reverse.. you see what Im saying. Here's the doozy. I can only use arrays, loops and c++ strings. So this means, no vectors, pointers c-strings (can't do char c[50]) as well as no c++ string iterators, so this means, no using the reverse function or swap or c.end or c.begin or whatever else there is. I can use .append and .size and what not.
I had an idea of doing something along the lines of
1 2 3 4 5
|
// to get 'x' amount of strings and store in variable
for (int i = 0; i < numOfLines; ++i)
{
getline(cin, str);
}
|
Since I can't use vectors or pointers or anything, I also thought about just adding the strings together? to get all the inputs into one variable but I'm not sure how to make it so it also adds the new line tab so instead of doing
enter string:
hello
world
// "helloworld"
/* hello
world */
I want it to save to a variable like the 2nd one.
All help is appreciated, like I said, I'm super limited to what I can use.