string userName;
string password;
...
cout << "Username: ";
cin >> userName;
...
cout << "Password: ";
cin >> password;
...
You can use getch() to read the input (but not displayed) and you can print out a "*" everytime you read a char.
eg:
void readPassword(char *arr) { int i=0;char c=0;
while((c=getch()) != 'r'){
arr[i]=c; putch('*'); /* Any character you like! */
i++;
} arr[i]='';
return; }
Thus you can read password, and display ******** instead.
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main(){
string password ="";
char ch;
cout << "Enter password::\n";
ch = _getch();
while(ch != 13){//character 13 is enter
password.push_back(ch);
cout << '*';
ch = _getch();
}
if(password == "Emmanuel"){
cout << "\nAccess granted :P\n";
}else{
cout << "\nAccess aborted...\n";
}
}
#include
#include
#include
#define MAX 500
main()
{
char password[MAX];
char p;
int i=0;
printf("Enter the password:");
while((p=getch())!= 13){
password[i++] = p;
printf("*");
}
password[i] = '\0';
if(i<6)
printf("\nWeak password");
else
printf("\nStrong password");
printf("\nYou have entered: %s",password);
getche();
}
The pseudo code is as follows:
char input [80] ;
puts ("Enter password") ;
gets (input) ;
if (strcmp (input, "secret") == 0)
{
puts ("Match!") ;
}
else
{
puts ("Wrong password") ;
}
Just use the random function.
To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.
write a c program that takes a binary file as input and finds error check using different mechanisms.
Active Time spent online
For a username, just get the username from the standard input using scanf and check whether this username matches with the username stored. If it doesn't match, then the username is wrong.For a password, get each character using getch(). Print a * for each character obtained. Now check this password with the stored password. If these don't match, then the password is wrong.
There is no need to write a C program for circuit analysis; there are lots of packages out there that already do that (for example, Spice).
To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.
write a c program that takes a binary file as input and finds error check using different mechanisms.
write a c++program by using if statement to read a number and check whether it is positive or negative
int main (void) { if ('C' == 'C') puts ("Okay"); else puts ('Oh, gosh"); return 0; }
Use the Exception class and type converters.
a c program for creat a virus
write a program in C to check whether a given number is apalindrome or not
Active Time spent online
Into the source program.
For a username, just get the username from the standard input using scanf and check whether this username matches with the username stored. If it doesn't match, then the username is wrong.For a password, get each character using getch(). Print a * for each character obtained. Now check this password with the stored password. If these don't match, then the password is wrong.
Write a c program to compute the surface area and volume of a cube
There is no need to write a C program for circuit analysis; there are lots of packages out there that already do that (for example, Spice).