How can I make my code repeat?

I have a Homework assignment due. I have it mostly done but i am drawing a blank on how to get it to repeat the program. The assignment is to write a program that when your type out a line of text like my name is robert99 12345 the text will return as robert99 *****. Which my program does but i cant get it to repeat the program at all I tried working with do while but was not able to figure it out.
This is what I have so far.
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using namespace std;
int main()

{


	
	int i;
	string st1;
	cout << "Now enter a line of text: ";
	getline(cin, st1);
	cout << endl;
	for (i = 0; i <= st1.length(); i++)
	{
		if (isdigit(st1[0]))
		{
			st1.at(i) = 'x';
			do
			{
				st1.at(i) = 'x';
				i++;
			} while (!isdigit(st1[i]));
		}
		if (st1[i] == ' ')
		{
			i++;
			while (isdigit(st1[i]))
			{
				st1.at(i) = 'x';
				i++;
			}
		}
	}
	cout << st1 << endl << endl;
	return 0;
}

Unfortunately I am as well not sure on how to do it, me being quite the beginner, but I would also go at it with a while loop of somehow. I know this doesn't really help much but maybe try and look at another program with a while loop or look at the tutorial for while loops. Hope you get it figured out!
Try this
1
2
3
while(true){
  //your code
}

or
1
2
3
do{
  //your code
}while(true)

or
1
2
3
for(;;){
  //your code
}

It'll repeat the code til reach break;
Topic archived. No new replies allowed.