changing all the characters of a string

I need to do a code that captures a string of random characters and a number, this separates the chain in 2 and then prints out each one, first the last letters of the chain and then the same amount of spaces of the first chain and then the first letters of the initial chain.
example:
write anything: abcd
enter number: 2
cd
ab
but i can't use cycles, i tried to change all the characters from the first printed chain into " " and then insert it to the second chain, but i can't get it to work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  #include <iostream>
#include <string>
#include <cstring>

using namespace std;
int main(){

	int num, i = 0;
	string chaine, chaine1, chaine2,chaine3;

	cout << "write anything : ";
	cin >> chaine;
	cout << "enter a number: ";
	cin >> num;

	chaine1 = chaine.substr(entier , chaine.size() - entier+1);
	chaine2 = chaine.substr(0, entier);

	chaine3 = strset(chaine1," ");
	chaine2.insert(0,chaine3);

	cout << chaine1 << endl;
	cout << chaine2 << endl;

	while (true){}
	return 0;
}
First, explain cycles. Are you saying you can't use loops? Or are you saying you're not allowed to use dynamically allocated variable types, such as vectors and dynamic arrays?
Topic archived. No new replies allowed.