Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ITCproj2.cpp : Defines the entry point for the console application.
- //
- #include<iostream>
- using namespace std;
- void findAuthorsAndPaperDetails(char[], char[], char[], char[], char[]);
- int searchNamesIndex(char[],char[], int);
- int adjustIndexToStartOFRecord(char[], int);
- int main()
- {
- char authors_list[1000]="$Talha Dar,Ibrahim Ahmed$Asfand Yaar,Abdulrahman Ahsan";
- char titles_list[1000]="$Paper 1 title$Paper 2 Title$Paper 3 Title";
- char venue_list[1000]="$Venue1$Venue 2$Venue 3";
- char details_list[1000]="$12.3,12,01,09,2000$45.6,45,02,09,2000$09.8,76,54,32,2000";
- char name[50]={'\0'};
- int choice=-1;
- cout<<"\nWelcome to reference manager MLA format."<<endl;
- while(choice!=0)
- {
- cout<<"\nEnter Name of an author, ending with a fullstop. This will print the paper associated with this author and it's details. ";
- cout<<"\nENTER NAME: ";
- cin.getline(name, 50, '.');
- findAuthorsAndPaperDetails(authors_list, titles_list, venue_list, details_list, name);
- cout<<"Enter 1 if you'd like to continue searching for more authors and papers, or enter 0 to terminate program.";
- cout<<"\nEnter Choice: ";
- cin>>choice;
- }
- return 0;
- }
- void findAuthorsAndPaperDetails(char authors[], char titles[], char venues[], char details[], char nameToSearch[]) //so far this functions only finds and prints the names of the authors, if one of the two is found.
- {
- int a=0, b=0, c=0;
- int count=0;
- int index=-1;
- bool found=false;
- while(found=false)
- {
- found=true;
- if(authors[a]=='$'){count++;}
- if(authors[a]==nameToSearch[0])
- {
- index=searchNamesIndex(authors, nameToSearch, a);
- if(index==-1){found=false;}
- }
- }
- cout<<endl;
- for(int x=index; authors[index]!='\0'; x++)
- {
- cout<<authors[x];
- }
- }
- int searchNamesIndex(char authors[], char name[], int i) //Once, first letter of input name==a letter in author's list, the process of matching the rest of the name to an authors name begins here.
- {
- bool found=true;
- int x=0;
- int index=0;
- for(int y=i; authors[y]!='\0' || authors[y]==',';y++)
- {
- if(authors[y]!=name[x]){return -1; found=false;}
- x++;
- }
- if(authors[i-1]==',')
- {
- index=adjustIndexToStartOFRecord(authors, i);
- }
- index=i;
- return index;;
- }
- int adjustIndexToStartOFRecord(char data[], int i) //If name found is the second of two names in the record, the index is adjusted to the start of first name.
- {
- int x=0;
- for(x=i; data[x]!='$'; x--)
- {
- }
- return x+1;
- }
Add Comment
Please, Sign In to add comment