Thursday 7 May 2015

SOCIAL NETWORKING WEBSITE- MY school project


Assume MYNETWORK.COM a social networking website.
Now adding,modifying and deleting account will be taken place on MYNETWORK.COM server.
 

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<fstream.h>
class user
{       char name[20];
        char id[15];
        char password[5];
        char mobno[10];

int uniqno;
        public:
        void getdata(void);
        void display(void);
        int getuniqueno()
        { return uniqno ; }
    void modify();
} s1,d,obj[3],obj2[3] ;

    void user::getdata(void)
      { cout<<"\n Enter name:- ";
       gets(name);
       cout<<"\n Enter username:- ";
       gets(id);
       cout<<"\n  Enter your password (password should NOT be more then 5 character)"  ;
        int i=0;
        while(i<5)
        {
        password[i]=getch();
        cout<<"*";
        ++i;
        }
        cout<<"\nEnter 10 digit mobile number:- ";
        gets(mobno);
    cout<<"\nEnter your own unique number(this use in modifying and deleting account)";
    cin>>uniqno;
         }
    void user ::display(void)
       { cout<<"\nYour Name          :- " <<name;  cout<<"\n";
         cout<<"\nYour email id       :- "<<id<<"@mynetwork.com" ; cout<<"\n";
         cout<<"\nYour Mobile number :- "<<mobno; cout<<"\n";
         cout<<"\n Your Unique number:- "<<uniqno;cout<<"\n";
         }
    void user::modify()
    { cout<<"\nYour Name          :- " <<name;  cout<<"\n";
          cout<<"\nYour email id       :- "<<id<<"@mynetwork.com" ; cout<<"\n";
          cout<<"\nYour Mobile number :- "<<mobno; cout<<"\n";
        char nm[20]=" ",cl[15]=" ",psd[5],mbn[10];
      cout<<"\nNew name:(enter '.' to retain old one)";
        gets(name);
      cout<<"\nNew username:(enter '.' to retain old one)";
        gets(cl);
      cout<<"\nNew password:(enter '1234' to retain old one)";
       
        int op=0;
        while(op<5)
        {
        psd[op]=getch();
        cout<<"*";
        ++op;

        }
      cout<<"\nNew mobile number:(enter '.' to retain old one)";
        gets(mbn);
    if(strcmp(nm,".")!=0)
    strcpy(name,nm);
    if(strcmp(cl,".")!=0)
    strcpy(id,cl);
    if(strcmp(psd,"1234")!=0)
    strcpy(password,psd);
    if(strcmp(mbn,".")!=0)
    strcpy(mobno,mbn);
}

    int n;

         int main()
{

        clrscr();
         const int a=12;
         int ch ,ch2;


          cout<<"\n................................................................................"      ;
          cout<<"\n................................................................................"    ;
      cout<<"\n                  WELCOME     -       TO      -       MYNETWORK   "  ;
          cout<<"\n................................................................................";
          cout<<"\n................................................................................" ;
          cout<<"\n Menu ";
      cout<<"\n Enter 1 - for create account";
      cout<<"\n Enter 2 - for modify exiting account";
      cout<<"\n Enter 3 - for deactivate exiting account";
      cout<<"\n Enter 4 - for return to previous page";
      cout<<"\n Enter your choice:";
        cin>>ch2;
      cout<<"\n" ;
  {
      if (ch2==1)
        {fstream filin;
        filin.open("serverss.dat",ios::in|ios::out);
        if(!filin)
         {cout<<"\n file not present on disk ..canceling...";
          return 1;
          }

             cout<<"\n                 Now create an account \n";
        cout<<"How many accounts you want to create(create only 3 account at a time)";
                      cin>>n;
        for (int ab=0;ab<n;ab++)
        {cout<<"\nEnter your "<<(ab+1)<<" (st/nd/rd) account details";
         obj[ab].getdata();
                  filin.write((char*)&obj[ab],sizeof(obj[ab]));

        }
                 { cout<<"\nEnter this code ... 12 ...in verification box ";
                  cout<<"\nEnter verification code:- ";
                  cin>>ch;
                  if(ch!=a)
                  { exit(1);
                   }
                 }
                 filin.seekg(0);
          cout<<"\n....Your account details are....  ";
          filin.seekg(0);
            for(int r=0;r<n;r++)
            {cout<<"\n Your "<<(r+1)<<" (st/nd/rd) account details are- ";
            filin.read((char*)&obj[r],sizeof(obj[r]));
                  obj[r].display();
        }
                  filin.close();
                 cout<<"\n................................................................................";
                 cout<<"\n................................................................................";
                  cout<<"\n YOUR ACCOUNT HAS BEEN SUCCESFULLY CREATED ";
                  cout<<"THANK YOU FOR CREATING ACCOUNT IN" ;
                  cout<<"  \n           WORLD MOST POPULAR SOCIAL NETWORKING WEBSITE CALLED-   ";
                  cout<<"\n.....................MYNETWORK.COM OF HIMANSHU SINGH......................";
                  cout<<"\n................................................................................";
                  cout<<"\n................................................................................";
}

 if(ch2==2)
{
        {
            fstream fio;
        fio.open("serverss.dat",ios::in|ios::out|ios::binary);
        int un;
        long pos;
    cout<<"\n Enter your unique number for modify";
    cin>>un;
    {pos=fio.tellg();
    fio.read((char*)&s1,sizeof(s1));
    if (s1.getuniqueno()==un)
    { s1.modify();
    fio.seekg(pos);
    fio.write((char*)&s1,sizeof(s1));
    cout<<"YOUR ACCOUNT WAS MODIFIED";

    }
    break;
    }
    fio.close();
    }
}
if(ch2==3)
{int unw;
cout<<"\n Enter your account's unique number for deactivate";
cin>>unw;
      ifstream op;
ofstream it;
op.open("serverss.dat",ios::in|ios::out|ios::binary);
it.open("atvid.dat");
while(!op.eof())
 { op.read((char*)&d,sizeof(d));
   if(d.getuniqueno()!=unw)
    it.write((char*)&d,sizeof(d));
 }
cout<<"YOUR ACCOUNT HAS BEEN DEACTIVATED";
}
if(ch2==4)

    {exit(3);
    }

}

getch();
return 0;


}

No comments:

Post a Comment