Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <string.h> //para usar o strcmp()
- using namespace std;
- int main(){
- char user[30],password[7]; // variaveis
- int retornoU=-10,retornoP=10; // user: gabriel | password : 1234
- /*
- 0: igual
- <0 str 1 menor que string 2
- >0 str 1 maior que string 2
- */
- while(retornoU!=retornoP){
- cout <<"user: ";
- cin >>user;
- retornoU=strcmp(user,"gabriel"); //verifica se as strings sao iguais e retorna 0 se for igual
- system("cls"); // limpeza
- if(retornoU==0){ // se o usuario digitado pelo usuario for igual ao salvo na maquina
- while(retornoP!=0){
- cout<<"user: " << user <<endl;
- cout <<"password: ";
- cin >>password;
- retornoP=strcmp(password,"123456"); //verifica se as strings sao iguais e retorna 0 se for igual
- system("cls"); //limpeza caso seja errado
- }
- }
- }
- cout<< "Acesso permitido!\nBem vindo Gabriel\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement