I am trying to make a password prompt using C++. My code is given below:
#include <iostream>
#include <string>
std::string operator * (std::string a, unsigned int b) {
std::string output = "";
while (b--) {
output += a;
}
return output;
}
int main(){
std::string pword;
std::string user;
std::cout << "Enter username: ";
std::cin >> user;
std::cout << "Enter password for user '" << user << "': ";
std::cin >> pword;
std::string pword_asterix = ("*") * pword.length(); // ERROR
std::clog << "Noted user '" << user << "' and password '" << pword_asterix << "'.";
But I'm getting the following error from Visual Studio Code:
expression must have arithmetic or unscoped enum type(Line 17)
What should I do?