Jul 22, 2021 at 6:30pm UTC
I said it lies in link. You can both run it and see code by clicking the code section.
Jul 22, 2021 at 6:34pm UTC
Here is the computer program found at the linked website
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
#include <iostream>
using namespace std;
void space() {
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
cout << endl;
}
int main()
{
cout << "NikPolo Command Terminal \n v.0.1.3" << endl;
string user, pswrd, checkuser, checkpswrd;
bool whileterminal = true ;
bool while_login = true ;
bool while_pswrd = true ;
bool while_user = true ;
while (while_user) {
cout << "Write new username: " ;
cin >> user;
cout << "Save username? Write yes or no: " ;
string yesno;
cin >> yesno;
if ("yes" == yesno or "y" == yesno) {
while_user = false ;
cout << "Saved!" << endl;
}
else {
continue ;
}
}
while (while_pswrd) {
cout << "Write new password: " ;
cin >> pswrd;
cout << "Save password? Write yes or no: " ;
string yesno2;
cin >> yesno2;
if ("yes" == yesno2 or "y" == yesno2) {
while_pswrd = false ;
cout << "Saved!" << endl;
}
else {
continue ;
}
}
space();
while (while_login) {
cout << "Login: " << endl;
cout << "Write username: " ;
cin >> checkuser;
cout << endl;
cout << "Write password: " ;
cin >> checkpswrd;
cout << endl;
if (checkuser == user) {
if (checkpswrd == pswrd) {
space();
space();
while_login = false ;
cout << "Login Complete!" << endl;
}
else {
cout << "Incorrect password or username" << endl;
cout << endl;
}
}
else {
cout << "Incorrect username or password" << endl;
cout << endl;
}
}
while (whileterminal) {
cout << endl;
string commands;
cout << "polo - " << user << " >> " ;
getline(cin, commands);
if (commands == "exit" ) {
cout << endl;
cout << "Confirming exit..." << endl;
system("pause" );
whileterminal = false ;
}
else if (commands == "" ) {
continue ;
}
}
}
Last edited on Jul 22, 2021 at 6:35pm UTC
Jul 22, 2021 at 10:59pm UTC
Using the line numbers in mbozzi 's post:
Line 6-80: Have you never heard of a loop?
Jul 23, 2021 at 6:43am UTC
It never writes just "username" as you say. What line is repeated?
Jul 23, 2021 at 6:47am UTC
It repeats this: polo - “any username” >>
And it shouldn’t repeat. Only when you wrote a command it should do something and write that again, but I never wrote any commands and it still duplicates in beginning
Jul 23, 2021 at 8:12am UTC
We prefer you to post your code/outputs here. Links that will be later removed are no good to anyone.
Jul 23, 2021 at 10:00am UTC
Can you write this code again seeplus, so it using namespace std, as I don’t understand much of the code because of std::
Jul 23, 2021 at 10:04am UTC
seeplus.
So I what I need to change in code, to stop it doing that?
Jul 23, 2021 at 12:17pm UTC
Can you write this code again seeplus, so it using namespace std, as I don’t understand much of the code because of std::
Why not? What's not to understand between:
and
The first looks for string in the namespace(s) specified in using statements. The second explicitly says to use the std namespace version.
Last edited on Jul 23, 2021 at 4:06pm UTC
Jul 23, 2021 at 3:37pm UTC
seeplus, did you mean string instead of sting in the first code snippet?
I know I make lots of typos myself.
Jul 23, 2021 at 3:40pm UTC
seeplus, I repeat again, what do I need to fix in it? Do
Jul 23, 2021 at 4:07pm UTC
seeplus can you answer me? Question is on top of yours
Jul 23, 2021 at 4:12pm UTC
Man, don’t get aggressive….I just asked. So what do I need to change in my code(I don’t want change whole thing as it used time to write all…) ? Do I need to have: “cin >> ws, commands” instead of “cin, commands” in getline()?
Jul 23, 2021 at 4:18pm UTC
Our previous posts crossed.
Do I need to have: “cin >> ws, commands” instead of “cin, commands” in getline()?
If you have using namespace std at the top, then you don't need std:: in front of the library functions, classes etc. Having std:: though is good practice.
Yes - as that removes the white-space left by the >> extraction before getline() extracts its data.
Last edited on Jul 23, 2021 at 4:20pm UTC