Тема: Поможіть перевести из int в char!
Мені потрібно щоб логін і пароль був не тільки цифри,но і букви.
#include "StdAfx.h"
#include <iostream>
#include "windows.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
setlocale(LC_ALL, "Russian");
int i, a,n=0, k=0, user_login, user_password, new_password;
struct auth
{
int login;
int password;
};
struct auth mas[5];
mas[0].login=2222;
mas[0].password=1111;
mas[1].login=3333;
mas[1].password=2222;
mas[2].login=4444;
mas[2].password=3333;
mas[3].login=5555;
mas[3].password=4444;
mas[4].login=6666;
mas[4].password=5555;
main:
cout<<"Vvedite login:"<<"\n";
cin>>user_login;
cout<<"Vvedite parol:"<<"\n";
cin>>user_password;
if(k<=2)
{
if (((user_login==mas[0].login)&&(user_password==mas[0].password)) || ((user_login==mas[1].login)&&(user_password==mas[1].password)) || ((user_login==mas[2].login)&&(user_password==mas[2].password)) || ((user_login==mas[3].login)&&(user_password==mas[3].password)) || ((user_login==mas[4].login)&&(user_password==mas[4].password)))
{
system("cls");
cout<<"Dobro pazhalovat"<<" "<<user_login<<"!"<<"\n";
k=0;
cout<<"Dlya prodovzhennya nazhmite_[1]"<<"\n";
cin>>a;
if (a==1)
{
goto change_password;
}
else
{cout<<"Nepravilniy vvod"<<"\n";
goto main;
}
}
else
{
k++;
if (k==3)
{
system("cls");
cout<<"Dostub zablokovaniy!Vy vukorustali 3 popitki!"<<"\n";
getch();
exit(EXIT_SUCCESS);
}
else
{
system("cls");
cout<<"Neverniy login abo parol"<<"\n";
printf("U vas ostolos %d popitok!\n\n",3-k);
goto main;
}
}
}
change_password:
if (user_login==6666)
{
cout<<"U vas est prava administratora."<<"\n";
cout<<"Dlya zminu parolya,nazhmine________________[1]"<<"\n";
cout<<"Dlya prosmotra vsei bazy___________________[2]"<<"\n";
cin>>n;
if(n==1)
{
system("cls");
cout<<"Vvedite login korustuvacha, parol yakogo vu hochete zminutu"<<"\n";
if_login_error:
cin>>user_login;
for (i=0; i<=4; i++)
{
if (user_login==mas[i].login)
{
system("cls");
cout<<"Vvadite novuy parol dlya korustuvacha"<<user_login;
cin>>new_password;
mas[i].password=new_password;
system("cls");
cout<<"Parol korustuvacha"<<" "<<user_login<<"uspishno zminenuy"<<"\n";
goto main_menu;
}
}
system("cls");
cout<<"Oshibka!Takogo korustuvacha ne isnuye!Povtorit sprobu"<<"\n";
goto if_login_error;
}
else if(n==2)
{
system("cls");
for(i=0; i<=4; i++)
{
printf("Login: %d\nParol: %d\n\n", mas[i].login, mas[i].password);\
}
}
else
{
cout<<"Neverniy vibor!Povtorite popitku!";
}
}
else
{ m0:
cout<<"Vvedite noviy parol:"<<"\n";
cin>>new_password;
switch(user_login)
{
case 2222:
mas[0].password=new_password;
break;
case 3333:
mas[1].password=new_password;
break;
case 4444:
mas[2].password=new_password;
break;
case 5555:
mas[3].password=new_password;
break;
case 6666:
mas[4].password=new_password;
break;
}
system("cls");
cout<<"Vash parol uspishno zmineniy"<<"\n";
main_menu:
cout<<"Dlya povernennya v glavnoe menu, nazhmine__[1]"<<"\n";
main_error:
cin>>n;
if (n==1)
{
system("cls");
goto main;
}
else
{
system("cls");
cout<<"Oshibka vvoda!Povtorite popitku!"<<"\n";
goto main_error;
}
}
getch();
}