Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include <fstream>
- #include<string.h>
- #include <sstream>
- #include <cstdlib>
- //strtol(s.c_str(),0,10);
- using namespace std;
- void ScreenLogo()
- {
- printf("\n\n\n\n\n==============================================================\n");
- printf(" \t [A] : To Add Record Choose A\n");
- printf(" \t [D] : To Display Record Choose D\n");
- printf(" \t [E] : To Exit E\n");
- printf("==============================================================\n\n\n\n\n");
- }
- int IndexID()
- {
- int c=0;
- ofstream record,index;
- index.open("index.txt");
- record.open("record.txt");
- while(!index.eof())
- c++;
- return c++;
- }
- void Add(char &control)
- {
- ofstream record,index;
- index.open("index.txt");
- record.open("record.txt");
- int ID,Age;
- char Name[100];
- ID = IndexID();
- cout<<"\nEnter Age : \n";
- cin>>Age;
- cout<<"\nEnter Your Name : \n";
- cin>>Name;
- index<<ID;
- record<<ID<<"|"<<Name<<"|"<<Age;
- cout<<"\n\n\n\n Your ID is "<<ID;
- ScreenLogo();
- cout<<"[+] Choose An Option : ";
- cin>>control;
- }
- void Display(char &control)
- {
- int ID,flag=0;
- ifstream records;
- cout<<"Enter IndexID : ";
- cin>>ID;
- ifstream file("index.txt");
- records.open("record.txt");
- string line;
- while(getline(file,line))
- {
- int newline = strtol(line.c_str(),0,10);
- if(newline == ID)
- flag++;
- }
- if(flag)
- {
- //cout<<"\t\tIndexID is Stored in My Records";
- char output[100];
- while(!records.eof())
- {
- records >> output;
- char *pch;
- pch = strtok (output,"|");
- char Data[3];
- int i=0;
- while (pch != NULL)
- {
- if(i == 0)
- printf ("ID : %s\n",pch);
- if(i == 1)
- printf ("Name : %s\n",pch);
- if(i == 2)
- printf ("Age : %s\n",pch);
- pch = strtok (NULL, "|");
- i++;
- }
- //cout<<output;
- }
- }else{
- cout<<"\t\tIndex is not Found ";
- }
- ScreenLogo();
- cout<<"[+] Choose An Option : ";
- cin>>control;
- }
- int main()
- {
- ScreenLogo();
- char x;
- cout<<"[+] Choose An Option : ";
- cin>>x;
- while(x != 'E')
- {
- switch(x)
- {
- case 'A':
- Add(x);
- break;
- case 'D':
- Display(x);
- break;
- case 'E':
- exit;
- default:
- cout<<"[+] Choose An Option : ";
- cin>>x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement