#include <limits>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fstream>
#include <string>
using namespace std;
int read_pin(bool PIN){
int input=0;
int n=0;
int max_prob;
if (PIN){
max_prob=4;
}
else{
max_prob=1000;
}
while(n<max_prob){
char ch = getch();
if (ch=='\r') break;
if (isdigit(ch)){
input *= 10;
input +=ch-'0';
n++;
if(PIN){
cout<<"*";
}
else{
cout<< ch;
}
}
}
cout << endl;
return input;
}
int main(int argc, char** argv)
{
int x ;
int PIN;
int saldo;
int liczba_prob=2;
HANDLE hOut;
hOut = GetStdHandle( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute( hOut, FOREGROUND_BLUE );
cout << "Witam w banku";
SetConsoleTextAttribute( hOut, FOREGROUND_RED );
cout<<" AmberGold SA."<<endl;
SetConsoleTextAttribute( hOut, FOREGROUND_BLUE );
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN );
ofstream plik;
int proba=2;
for (int i=0; i<3;i++){
int a;
cout << "Prosze wprowadzic PIN: ";
a=read_pin(true);// tu ma wczytywać z pliku
if(a==PIN){
while(a==PIN) {
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN );
cout<<"Poprawne dane"<<endl;
SetConsoleTextAttribute( hOut, FOREGROUND_INTENSITY );
cout<<"[";
for(int ladowanie=0; ladowanie<=20; ladowanie++){
cout<<"|";
Sleep(250);
}
cout<<"]"<<endl;
system("PAUSE");
system("cls");
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN );
for(int i;i=5;) {
cout <<endl;
cout<<" MENUE GLOWNE" <<endl;
SetConsoleTextAttribute( hOut, FOREGROUND_INTENSITY );
cout<<" ---------------- "<<endl;
cout<<left<<"|";
SetConsoleTextAttribute( hOut, FOREGROUND_RED );
cout<<" AmderGold SA.";
SetConsoleTextAttribute( hOut, FOREGROUND_INTENSITY );
cout<<" |"<<endl;
cout<<" ---------------- "<<endl;
SetConsoleTextAttribute( hOut, FOREGROUND_GREEN );
cout<<" 1. Stan kata" <<endl;
cout<<" 2. Wplac pieniadze" <<endl;
cout<<" 3. Wyplac pieniodze" <<endl;
cout<<" 4. Zmiana PIN'u " <<endl;
cout<<" 5. KONIEC" <<endl;
cout<<endl;
i=getch();
switch(i)
{
case '1':
cout<<"Masz aktualnie "<< saldo-x <<" ziko"<<endl; //tu ma wczytywać z pliku
system("PAUSE");
system("cls");
break;
case '2':
cout<<"Ile chcesz wplacic"<<endl;
cin>>saldo;
system("cls");
break;
case '3':
cout<<"Ile chcesz wyplacic"<<endl;
cin>>x;
if(x>=1000){
}
system("cls");
break;
case '4':
cout<<"Podaj stary PIN: ";
cin>>PIN;
cout<<"Podaj nowy PIN: ";
cin>>PIN;
system("cls");// tu ma zmieniać PIN w pliku
break;
case '5':
exit(0);
break;
system("cls");
}
}
}
}
else
while(i==2){
cout<<"Karta zostala zablokowana. Zyce milego dnia ;-)"<<endl;
system("PAUSE");
exit(0);
return 0;
}
}
system("cls");
plik.close();
system("cls");
return 0;
}
Cześć, mam problem zapisem i odczytem pliku nie mam kompletnie pojęcia gdzie wstawić kod do zapisu pliku. Mam też problem z odczytem wartości z pliku. Będę wdzięczny z pomoc :-).