I'd go for the following solution using "carriage return":
for (int j = 0; j < 3; j++) {
cout << "\rLoading \rLoading";
for (int i = 0; i < 3; i++) {
cout << ".";
sleep(300);
}
}
This overwrites the current line (with all dots) and repostions cursor at the end of "Loading".
BTW, the sleep value here is in milliseconds. You may have to change that if yours is in seconds.
Also, in your program you have nested loops both with running i
- I doubt that this will work as intended...