I need a do while loop in this but when i try to put one in it errors alot could someone show me the proper placement please.

i use dev C++ compiler

//Login

#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int main()

{
   
   
    cout << "\tWelcome to Login\n";
    int security = 0;
    

    
    string username;
    cout << "\nUsername: ";
    cin >> username;
    
    string 
    password;
    cout << "Password: ";
    cin >> password;
    
    if (username == "echoestroy" && password == "561654")
    {
                 cout << "\nWelcome Echoestroy.";
                 security = 5;
    }
    
        if (username == "krissyk6" && password == "spike")
    {
                 cout << "\nWelcome Krissyk6.";
                 security = 5;
    }
    
        if (username == "cjochoate" && password == "troy")
    {
                 cout << "\nWelcome cjochoate.";
                 security = 5;
    }
    
        if (username == "guest" || password == "guest")
    {    
                 cout << "\nWelcome Guest.";
                 security = 1;
    }
    
    if (!security)
       cout << "\nYour login has failed. Please check your username and password and try again";
       

    getch(); 
    return 0;

}
//Login

#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int main()

{
   
   
    cout << "\tWelcome to Login\n";
    int security = 0;
    

    do {
    string username;
    cout << "\nUsername: ";
    cin >> username;
    
    string 
    password;
    cout << "Password: ";
    cin >> password;
    
    if (username == "echoestroy" && password == "561654")
    {
                 cout << "\nWelcome Echoestroy.";
                 security = 5;
    }
    
        if (username == "krissyk6" && password == "spike")
    {
                 cout << "\nWelcome Krissyk6.";
                 security = 5;
    }
    
        if (username == "cjochoate" && password == "troy")
    {
                 cout << "\nWelcome cjochoate.";
                 security = 5;
    }
    
        if (username == "guest" || password == "guest")
    {    
                 cout << "\nWelcome Guest.";
                 security = 1;
    }
    
    if (!security)
       cout << "\nYour login has failed. Please check your username and password and try again";
    } while (!security);
       

    getch(); 
    return 0;

}

this should work.

Well, it is fairly obvious where the changes are, but I added

do {

where the loop should start and just before the end theres:

} while (!security);

so that the loop will only break if the variable 'security' is true.

>Well, it is fairly obvious where the changes are, but I added
Not at a glance, especially with the messed up indentation you used, and I'm not interested enough to compare the two programs line by line to find your changes.

thanks guys i really fixed it like 15 mins after my post, i forgot to close it but kudos all around *claps*

This question has already been answered. Start a new discussion instead.