2013-05-29 1 views
1
#include <string> 
#include <iostream> 
#include <fstream> 
#include <windows.h> 
#include <wininet.h> 
#include <winsock.h> 
#include <stdio.h> 
#include <stdarg.h> 

#pragma comment(lib, "wininet.lib") 

using namespace std; 

const int file_l = 100; 

int getpage() 
{ 
    HINTERNET hOpen, hURL; 
    LPCWSTR NameProgram = L"Webreader";    //LPCWSTR == Long Pointer to Const Wide String 
    LPCWSTR Website;      
    char file[file_l]; 
    unsigned long read; 

    //Always need to establish the internet connection with this funcion. 
     if (!(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0))) 
     { 
      cerr << "Error in opening internet" << endl; 
      return 0; 
     }      
    Website = L"http://www.sec.gov/Archives/edgar/data/1535079/000100201413000137/R2.htm"; 
    hURL = InternetOpenUrl(hOpen, Website, NULL, 0, 0, 0);   //Need to open the URL 

    ofstream fout("Summer Research testing.txt"); 

    InternetReadFile(hURL, file, file_l, &read); 
    while (read == file_l) 
     { 
      InternetReadFile(hURL, file, file_l, &read); 
      file[read] = '\0'; 
      cout << file; 
      fout << file; 
     } 
    fout.close(); 

    cout << endl; 
    InternetCloseHandle(hURL); 
    return 0; 
} 

int main()  
{ 
    getpage(); 
} 

ci-dessus est mon code. Je suis un débutant. Programmation C++, en utilisant Visual Studio 2010

Je continue à avoir l'erreur: «d'exécution Échec de la vérification # 2 - Stack autour de la variable « fichier » a été corrompu »
ce que je pensais que je ne devrais pas faire le "* char fichier [file_l]; *" la même longueur que les autres, donc je l'ai changé pour "* fichier char [fichier_l + 1]; " Apparemment, le problème a résolu, plus d'erreur. Pourriez-vous s'il vous plaît laissez-moi savoir si c'est la bonne façon de corriger cette erreur?

En outre, le programme n'a pas imprimer tout le code HTML de la page Web dans le fichier "
" Summer Research tests.txt "*" comme je le voulais. il n'a pas imprimé à partir de la ligne 1 et a toujours arrêté à la ligne 209. J'ai changé les choses, mais très peu de progrès. aidez s'il vous plaît.

Toute aide est grandement appréciée!ERREUR: Échec de vérification de l'exécution # 2 - La pile autour de la variable 'fichier' a été corrompue

+1

[lire] = '\ 0'; provoquera un comportement indéfini si read == 100 puisque vous accédez 1 après la fin du tableau de fichiers. Votre correctif est correct. – drescherjm

+0

En ce qui concerne le problème avec le code HTML. Vous rejetez toujours la première lecture en ne sortant pas ce qui était dans le fichier avant la boucle while et en ne affichant pas non plus ce qui était dans le tableau de fichiers lors de la dernière lecture si la taille en lecture n'était pas de 100 octets. – drescherjm

+0

@drescherjm Merci beaucoup pour votre aide !! pourriez-vous s'il vous plaît expliquer ceci un peu plus? – Honeycrisp

Répondre

1

Copier de mes commentaires au message d'origine:
file [read] = '\ 0'; provoquera un comportement indéfini si read == 100 puisque vous accédez 1 après la fin du tableau de fichiers. Votre solution pour ce correct:

char file[file_l+1]; 

Pour le problème de sortie:
vous terminez d'utiliser la première lecture toujours en ne délivrant ce qui était dans le fichier avant que la boucle while et aussi ne montre pas ce qui était dans le tableau de fichiers sur le dernière lecture si la taille de lecture n'était pas de 100 octets.

Pour résoudre ce problème, je réécris votre boucle while un peu:

InternetReadFile(hURL, file, file_l, &read); 
while (read > 0) 
{ 
    // Something was read we should output it now! 
    file[read] = '\0'; 
    cout << file; 
    fout << file; 
    InternetReadFile(hURL, file, file_l, &read); 
} 

En déplaçant le deuxième InternetReadFile() pour après le code qui les délivre nous se ne jeter la première lecture sans délivrer en sortie. Aussi j'ai changé la comparaison pour lire> 0 pour résoudre 2 problèmes: Les lectures de moins de 100 octets et la lecture finale.

J'ai inclus les corrections dans mes modifications apportées à votre code ici:

#include <string> 
#include <iostream> 
#include <fstream> 
#include <windows.h> 
#include <wininet.h> 
#include <winsock.h> 
#include <stdio.h> 
#include <stdarg.h> 

#pragma comment(lib, "wininet.lib") 

using namespace std; 

const int file_l = 100; 

int getpage() 
{ 
    HINTERNET hOpen, hURL; 
    LPCWSTR NameProgram = L"Webreader";    //LPCWSTR == Long Pointer to Const Wide String 
    LPCWSTR Website;      
    char file[file_l+1]; // Add an additional character for '\0' 
    unsigned long read; 

    //Always need to establish the internet connection with this function. 
    if (!(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0))) 
    { 
     cerr << "Error in opening internet" << endl; 
     return 0; 
    }      
    Website = L"http://www.sec.gov/Archives/edgar/data/1535079/000100201413000137/R2.htm"; 
    hURL = InternetOpenUrl(hOpen, Website, NULL, 0, 0, 0);   //Need to open the URL 

    ofstream fout("Summer Research testing.txt"); 

    InternetReadFile(hURL, file, file_l, &read); 
    while (read > 0) 
    { 
     // Something was read we should output it now! 
     file[read] = '\0'; 
     cout << file; 
     fout << file; 
     InternetReadFile(hURL, file, file_l, &read); 
    } 
    fout.close(); 

    cout << endl; 
    InternetCloseHandle(hURL); 
    return 0; 
} 

int main()  
{ 
    getpage(); 
} 
+0

Merci beaucoup pour votre aide! apprécier grandement!! c'est bien! – Honeycrisp

+0

Pourrais-je poser une autre question? Je travaille actuellement sur la façon de supprimer les balises HTML que j'ai obtenues sur la page Web. alors j'ai trouvé que cette fonction while ne lisait pas la phrase ligne par ligne, et j'ai perdu mon chemin un peu. Pourriez-vous s'il vous plaît m'aider un peu? Merci! – Honeycrisp

+0

Rappelez-vous que html n'a pas besoin d'avoir de nouvelle ligne du tout (cela peut être une seule ligne), donc le fait de la diviser en newlines ne fonctionnera pas dans tous les cas. Quoi qu'il en soit, pour résoudre votre problème, vous pouvez faire du fout un stringstream et le traiter après la lecture (après l'appel InternetCloseHandle()). – drescherjm

0

lire ne devrait jamais être> = file_l! Cela signifie que vous devez écrire

while (read == file_l - 2) 

et

file[read-1] = '\0'; 

(file_l - 2 parce que le dernier octet doit être réservé pour « \ 0 ») J'espère que vous vous rendez compte que la boucle while vos déclarations seulement si le tampon "read" (qui devrait être de type LPVOID et non char *) est plein. Par ailleurs, votre application est presque entièrement écrite en C, pas en C++.

+0

À partir de la documentation msdn pour InternetReadFile, je crois que read sera égal à file_1 quand il y aura au moins 1 octet de fichier à lire. – drescherjm

-1
#include<iostream> 
#include<string> 
#include<stdlib.h> 
#include<conio.h> 
#include<fstream> 
#include<string.h> 
using namespace std; 

class Date 
{ protected: 
    int Day; 
    int month; 
    int year; 

public: 


    Date() 
    { 
     this->Day=01; 
     this-> month=01; 
     this-> year=1990; 

    } 
    Date(int _day,int _month,int _year) 
    {this-> Day=_day ; this-> month=_month; this-> year=_year; 


    } 


    void display() 
    { 

     cout<<" Day/month/year :"<<Day<<"/"<<month<<"/"<<year<<endl; 

    } 


}; 
class Login 
{ 
protected: 
string UserName; 
char password[6]; 

public: 


    Login() 
{ 
    this->UserName="User"; 
    this-> password[6]='1','2','3','4'; 

} 


Login (string user,char pass[6]) 
{ 
    this->UserName=user; 
    this->password[6]=pass[6]; 

} 
void setUser(string a) 
{ 
    this->UserName=a; 
} 
void setPass(char c[6]) 
{ 
this->password[6]=c[6]; 

} 

string getuser() 
{ 

    return this->UserName; 
} 
char getPass() 
{ 
    return this->password[6]; 

} 


}; 



class customer 
{ 
protected: 
    string Name; 
    string Address; 
    int age; 
    int customer_no; 
    Date DOfReg ; 
    Date DOfBirth ; 
    string contact_no; 
    Login A ; 

    friend class Admin; 

public: 

    ofstream f; 

     customer() 
     { 
      age=customer_no=0; 
     } 
       customer (string _Name ,string _Address,int _age,int _customerNo,Date DOB,Date DOR,string contactNo,Login a) 
       { 

        this-> Name=_Name; 
       this-> Address=_Address; 
       this-> age=_age; 
       this-> customer_no=_customerNo; 
       this-> DOfReg= DOR ; 
       this-> DOfBirth= DOB ; 
       this-> contact_no = contactNo; 
       this-> A=a; 

     f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
       } 

       void setName(string name) { this->Name=name;} 
       void SetAddress(string add) { this->Address=add;} 
       void setAge(int Age) { this->age=Age;} 
       void SetCutomer(int no) {this->customer_no=no;} 
       void setDOR(Date dor) {this->DOfReg=dor;} 
       void setDOb(Date dob) { this-> DOfBirth=dob;} 
       void setContact(string contact) { this-> contact_no=contact;} 
       void setLogin(Login ID) { this-> A=ID;} 


       virtual void passchange(Login ID) 
       {} 
       virtual bool checkID(Login) 
     { return 0; 
     } 



     virtual void Reg() 
     { 


     } 

     virtual void updateinfo() 
     { 

     } 

     virtual void Show() 
     { 


     } 

     virtual float paymentType() 
     { 
      return 0; 

     } 



}; 
class Admin 
{ 
protected: 
    Login A; 
public: 
    ofstream f; 
    Admin() 
    { 
     string Y="Admin"; char z[5]={"4321"}; 
     A.setUser(Y); 
     A.setPass(z); 
    cout<<z[5]; 
    } 

Admin(Login ID) 
    { 
     A=ID; 


    } 

    bool checkID(Login ID) 
    { 
     if(A.getuser()==ID.getuser()&&A.getPass()==ID.getPass()) 
     {return true; 
     } 
     else return false; 


    } 


    void Reg(customer& a) 
    { 

        int c=0; 
       cout<<"Enter Name :"<<endl; 
       getline(cin,a.Name); 
       cin.ignore(); 
       cout<<"\nEnter Address :"<<endl; 
       getline(cin,a.Address); 
       cout<<"\nEnter Age :"<<endl; 
       cin>>a.age; 
       a.customer_no=c; 
       int q,b,d; 
     do{ 
      cout<<"\nEnter Date Of Regestration ";  cout<<"Format: DD/MM//YYYY"<<endl; 

       cin>>q; 
       cin>>b; 
       cin>>d; 
       if (q<=31&&b<=12&&d<2014) 
       { Date DOR(q,b,d); 
        a.DOfReg = DOR ;break; 
       } 
     }while(q>31&&b>12&&d>2013); 

       do 
       { 
        cout<<"\nEnter Date Of Birth ";   cout<<"Format: DD/MM//YYYY"<<endl; 

        cin>>q;cin>>b;cin>>d; 
       if (q<=31&&b<=12&&d<2014) 
       { 
        Date DOB(q,b,d); 
        a.DOfBirth= DOB ;break;} 
       else {cout<<"\nWrong Format/Date :"<<endl;} 

       }while(q>31&&b>12&&d>2013); 
       cout<<"\nEnter Your Contact No. :";  cout<<"Format: 0322-1234567 "<<endl; 
       getline(cin,a.contact_no); 
cin.ignore(); 
     c++; 
    f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
f.close(); 
    } 

}; 

class PTCL : public customer 
{ 
protected: 

public: 
    fstream f; 

    void Reg() 
     { 
      int c=0; 
      cin.clear(); 
       cin.ignore(); 
       cout<<"\nEnter Name :"<<endl; 
       getline(cin,Name); 
       cin.ignore(); 
       cout<<"\nEnter Address :"<<endl; 
       getline(cin,Address);cin.ignore(); 
       cout<<"\nEnter Age :"<<endl; 
       cin>>age; 
       customer_no=c; 
       int a; 
        int b; 
        int d; 
     //do{ 
      cout<<"\nEnter Date Of Regestration ";  cout<<"Format: DD/MM//YYYY"<<endl; 

       cin>>a;cin>>b;cin>>d; 
    //   if (a<=31&&b<=12&&d<2014) 
       Date DOR(a,b,d); 
        DOfReg = DOR; //break; 
        //else {cout<<"\nWrong Format/Date :"<<endl;} 
    // }while(a>31&&b>12&&d>2013); 

     //  do 
      // { 
       // cout<<"\nEnter Date Of Birth ";   cout<<"Format: DD/MM//YYYY"<<endl; 

       // cin>>a;cin>>b;cin>>d; 
//    if (a<=31&&b<=12&&d<2014) 
    //   { 
        //Date DOB(a,b,d); 
        //DOfBirth= DOB ;//break; 
      // } 
     //  else {cout<<"\nWrong Format/Date :"<<endl;} 

      // }while(a>31&&b>12&&d>2013); 

      cin.clear();cin.ignore();  cout<<"\nEnter Your Contact No. :";  cout<<"Format: 0322-1234567 "<<endl; 
       getline(cin,contact_no);cin.ignore(); 

     c++; 
    f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); } 

    void passchange(Login ID) 
    { 
     cout<<"Enter New UserName :"<<endl; 
     string User; 

     getline(cin,User); 
     A.setUser(User); 
     char c[5]; 
     cout<<"Enter New Password Of 4 letters"<<endl;; 
     cin>>c[5]; 
     A.setPass(c); 
     f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 

    } 


    bool checkID(Login ID) 
    { 
     if(A.getuser()==ID.getuser()&&A.getPass()==ID.getPass()) 
     {return true; 
     } 
     else return false; 


    } 


    void updateinfo() 
     { 
     int x=0; 
      cout <<"Which Info You Want to Update"<<endl; 
      cout<<"1. Name :" << Name<<endl; 
      cout<<"2. Address :"<< Address<<endl; 
      cout<<"3. Age :"<< age<<endl; 

      cout<<"4. Date Of Birth :"; DOfBirth.display(); cout<<endl; 
      cout<<"5. Contact No :"<<contact_no<<endl; 
      cout<<endl; 
      char choice; 

      do 
      { 
       cout<<"choice :"<<endl; 
       cin>>x; 

       if (x==1) 
      { cout<<"Enter New Name "<<endl; 
       getline(cin,Name); 
f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
      } 
       else if (x==2) 
      { 
      cout<<"Enter New Address "<<endl; 
      getline(cin,Address); 
f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
      } 
       else if(x==3) 
       { 
        cout<<"Update Your Age :"<<endl; 
        cin>>age; 
    f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close();  
       } 
       else if(x==4) 
       { 
        cout<<"Update Your Birth info:"<<endl; 
        int a,b,c; 
        cin>>a;cin>>b;cin>>c; 
        Date dOb(a,b,c); 
        setDOb(dOb); 

    f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
       } 
       else if(x==5) 
       { 
        cout<<"Update Your Contact No: "<<endl; 
        cin>>contact_no; 
       f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
     } 
       else 
       { 
       cout<<"Wrong input "<<endl; 
       } 
cout<<"Do Yo Want to Update More (Y/N):"<<endl; 
       cin>>choice; 
      }while(choice=='N'); 
      cout<<"Information Updated !! "<<endl; 
    } 

    void Show() 
    { 
      cout<<"1. Name :" << Name<<endl; 
      cout<<"2. Address :"<< Address<<endl; 
      cout<<"3. Age :"<< age<<endl; 
      cout<<"4. Date Of Birth :"; DOfBirth.display(); cout<<endl; 
      cout<<"5. Contact No :"<<contact_no<<endl; 
      cout<<"6. date of registration : "; DOfReg.display();cout<<endl; 
      cout<<"7. customer no. : "<<customer_no<<endl; 
      f.open("person.dat",ios::in|ios::out|ios::app); 
      ifstream f1; 
       f1.read(reinterpret_cast<char*>(this),sizeof (*this)); 

    } 

}; 

class dell : public customer 
{ 
protected: 
    string country; 
public: 
    fstream f; 
    dell() 
    { 

    country="USA"; f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
    } 

    dell(string _Name ,string _Address,int _age,int _customerNo,Date DOB,Date DOR,string contactNo,string count) 
     { 
       Name=_Name; 
       Address=_Address; 
       age=_age; 
       customer_no=_customerNo; 
       DOfReg= DOR ; 
       DOfBirth= DOB ; 
       contact_no = contactNo; 
       country=count; 
      f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
    } 

     bool checkID(Login ID) 
    { 
     if(A.getuser()==ID.getuser()&&A.getPass()==ID.getPass()) 
     {return true; 
     } 
     else return false; 


    } 

    void Reg() 
     { 
      string uName; int c=0;cin.ignore(); 
       cout<<"Enter Name :"<<endl; 
       getline(cin,Name); 
       cin.ignore(); 
       cout<<"\nEnter Address :"<<endl; 
       getline(cin,Address); 
       cout<<"\nEnter Age :"<<endl; 
       cin>>age; 
       customer_no=c; 
       int a,b,d; 
     do{ 
      cout<<"\nEnter Date Of Regestration ";  cout<<"Format: DD/MM//YYYY"<<endl; 

       cin>>a;cin>>b;cin>>d; 
       if (a<=31&&b<=12&&d<2014) 
       { Date DOR(a,b,d); 
        DOfReg = DOR ;break; break; 
       } 
     }while(a<=31&&b<=12&&d<2014); 

    cin.clear(); 
    do 
       { 
        cout<<"\nEnter Date Of Birth ";   cout<<"Format: DD/MM//YYYY"<<endl; 

        cin>>a;cin>>b;cin>>d; 
       if (a<=31&&b<=12&&d<2014) 
       { 
        Date DOB(a,b,d); 
        DOfBirth= DOB ; 
       break;} 
       else {cout<<"\nWrong Format/Date :"<<endl;} 

       }while(a<=31&&b<=12&&d<2014); 
       cin.clear(); 
      cin.ignore(); 
       cout<<"\nEnter Your Contact No. :";  cout<<"Format: 0322-1234567 "<<endl; 
       getline(cin,contact_no); 

      cin.clear(); 
      cin.ignore(); 
      cout<<"Create user Name "<<endl; 
      getline(cin,uName);cin.clear(); 
      cin.ignore(); 
char p[6]; 
cout<<"Create PassWord "<<endl;    ///// hERE is The Eror " stack around P was corrupted 
                even if I Input only 1 digit ! 

cin>>p[6]; 
A.setPass(p); 
A.setUser(uName); 
c++; 
    f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
      } 

void updateinfo() 
     { 
     int x=0; 
      cout <<"Which Info You Want to Update"<<endl; 
      cout<<"1. Name :" << Name<<endl; 
      cout<<"2. Address :"<< Address<<endl; 
      cout<<"3. Age :"<< age<<endl; 

      cout<<"4. Date Of Birth :"; DOfBirth.display(); cout<<endl; 
      cout<<"5. Contact No :"<<contact_no<<endl; 
      cout<<"6. country : "<<country; 
      cout<<endl; 
      char choice; 

      do 
      { 
       cout<<"choice :"<<endl; 
       cin>>x; 

       if (x==1) 
      { cout<<"Enter New Name "<<endl; 
       getline(cin,Name);cin.ignore(); 
       f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
      } 
       else if (x==2) 
      { 
      cout<<"Enter New Address "<<endl; 
      getline(cin,Address); cin.ignore();  
      f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
      } 
       else if(x==3) 
       { 
        cout<<"Update Your Age :"<<endl; 
        cin>>age; 
        f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
       } 
       else if(x==4) 
       { 
        cout<<"Update Your Birth info:"<<endl; 
        int a,b,c; 
        cin>>a;cin>>b;cin>>c; 
        Date dOb(a,b,c); 
        setDOb(dOb); 
        f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
       } 
       else if(x==5) 
       { 
        cout<<"Update Your Contact No: "<<endl; 
        cin>>contact_no;  
       f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (*this)); 
       f.close(); 
       } 
       else if(x==6) 
       { 
       cout<<"Update Country Name : "<<endl; 
       cin>>country; 
       f.open("person.dat",ios::in|ios::out|ios::app); 
       f.write(reinterpret_cast<char*>(this),sizeof (this)); 
       f.close(); 
       } 
       else 
       { 
       cout<<"Wrong input "<<endl; 
       } 
cout<<"Do Yo Want to Update again (Y/N):"<<endl; 
       cin>>choice; 
      }while(choice=='N'); 
      cout<<"Information Updated !! "<<endl; 
    } 

    void Show() 
    { 
    cout<<"1. Name :" << Name<<endl; 
    cout<<"2. Address :"<< Address<<endl; 
    cout<<"3. Age :"<< age<<endl; 
    cout<<"4. Date Of Birth :"; DOfBirth.display(); cout<<endl; 
    cout<<"5. Contact No :"<<contact_no<<endl; 
    cout<<"6. date of registration : "; DOfReg.display();cout<<endl; 
    cout<<"7. customer no. : "<<customer_no<<endl; 
    cout<<"8. country : "<<country<<endl; 

      ifstream f1; 
    f1.open("person.dat",ios::in|ios::out|ios::app);   f1.read(reinterpret_cast<char*>(this),sizeof (*this)); 

    } 
}; 

void main() 
{ 

    customer *ptr[100]; 

    string Name; 
    string Address; 
    int age; 
    int customer_no; 
    Date DOfReg; 
    Date dofbirth; 
    string contact_no; 
    string country; 

    int c; 
    int count; 
    char choice; 
    string User; 
    char Pin[6]; 
    int p; 
    for (int i=0;i<100;i++) 
    { 
        cout<<"\n\n********======================*******\n\n"<<endl; 
     cout<<" \n    Welcome To Customer Services   "<<endl; 

     cout<<"\n1. Login for Registerd Member (PTCL/UFONE) "<<endl; 
     cout <<"\n2. SignUp for Regestration (PTCL/UFONE) "<<endl; 
     cout<<"\n3. Search for Regesterd Memebers (Only for Admin) "<<endl; 
     cout<<"\Choice :"<<endl; 
     cin>>c; 

     if (c==1) 
     { 
      cin.ignore(); 
      cout<<"\n Enter User Name "<<endl; 
      getline(cin,User); 
      //std::cin.ignore(); 
      cout<<"\nEnter Pin of no More than 4 characters"<<endl; 
     for (int i=0;i<20;i++) 
    { 
    Pin[i]=getch(); 
    if (Pin[i]==13) 
    { 
    Pin[i]=0; 
    break; 
    } 
    if (Pin[i]!=8) 
    cout << "*"; 
    } 

     Login ID(User,Pin); //PassWord Sent Here; 

     if (ptr[i]->checkID(ID)) //Password match Check 
     { 


      cout<<"\n Welcome "<<endl; 
     cout<<"\n1. for Update Info "<<endl; 
     cout<<"\n2. for View Info "<<endl; 
     cout<<"\n3. for Pass change"<<endl; 
     cout<<"\n Choice "<<endl; 
     cin>>count; 

     if (count==1) 
     { 
      ptr[i]->updateinfo(); 
     } 
     else if(count==2) 
     { 
      ptr[i]->Show(); 

     } 
     else if(count==3) 
     { 
      ptr[i]->passchange(ID); 
     } 


     } //Check ID if bracket 
else { 

      cout<<"\nUserName Or PassWord is Invalid: "<<endl;} 
    }//c==1 bracket 
     else if (c==2) 
    { 
     cout<<"\nWhoose Customer You Want To be Dell(D)/PTCL(P) "<<endl; 
     cin>>choice; 
     if (choice=='D'||'d') 
     { 
      ptr[i] = new dell; 
      ptr[i]->Reg(); 
     } 
     else if (choice=='P'||'p') 
     { 
      ptr[i]=new PTCL; 
      ptr[i]->Reg(); 
     } 
     else {cout<<"\nWrong Choice" <<endl; 
     } 
    } 
    } 

getch(); 
} 
fichier
Questions connexes