Thursday, July 9, 2009

Reading text files and storing contents into a List C++?

Hi i want to read in a text file and store the contents into a list in C++. I am able to read in the file using fstream.





I have declared a list of type string however the contents of the text file has employee ID number which is of type int. Is is appropriate to store the employees into a list of type string?





How could i modify this code so i can store the contents into the "list "of employees?





Thanks.





Here is my attempted code:





#include %26lt;iostream%26gt;


#include %26lt;list%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;





using namespace std;





int main ()


{


int iQuit = 0;





list%26lt;string%26gt; employees;


cout %26lt;%26lt; "test";


return 0;





string str;


ifstream myFile("Employees.txt");





if(! myFile)


{


cout %26lt;%26lt; "Error opening the file" %26lt;%26lt;endl;


return -1;


}





while(! myFile.eof())


{


getline(myFile, str);


cout %26lt;%26lt; str %26lt;%26lt; endl;


}


myFile.close();


cin %26gt;%26gt; iQuit;


return 0;





}

Reading text files and storing contents into a List C++?
Unless you are going to perform some kind of math on the employee numbers, I don't see what the problem is representing them strings. You could save some small amount of space by storing them as integers but I doubt that is an issue here.





As for storing the contents of the lists just use the list push_back() method like so:





while (! myFile.eof())


{


getline(myFile, str);


cout %26lt;%26lt; str %26lt;%26lt; endl;


employees.push_back(str);


}





If you really do want to use integers basically all you need to do is to change to a list%26lt;int%26gt; for employees and convert the string to an int using atoi or a stringstream.


Help for computer c++ project banking?

have made a simple c++ program based on banking. without using graphics. i need answers for the following


1. need of computerisation


2. future enhancement in the program


this is a banking program:





Banking Project





Identifier used


Identifier Type Meaning


w float withdrawl amount


Identifier Type Meaning


1


2


3


4





5





w


type


mrno


scrnt





dispall()


Float


char


integer


integer





function


Withdrawal amount


Type of acc SAVING(s)/CURRENT(c)


Master record number


Whether screen is displaying record or not


Display all menu

















#include%26lt;fstream.h%26gt;


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;string.h%26gt;


#include%26lt;iostream.h%26gt;


#include %26lt;stdlib.h%26gt;


#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;


#include %26lt;dos.h%26gt;


void deposit(void);


void addrecord();


void delrecord();


void modrecord();


void disprecord();


void dispall();


void withdraw();


float w,z;


class account


{


int accountno,cls;


char name[30],type;


float deposit,withdraw;


public:


account()


{


deposit=withdraw=0;


}


int giveaccountno()


{


return accountno;


}





void getdata(int mrno)


{


accountno=mrno+1;


cout%26lt;%26lt;"ACCOUNT NUMBER :: ";


cout%26lt;%26lt;accountno%26lt;%26lt;" ";


cout%26lt;%26lt;"ENTER YOUR NAME :: ";


gets(name);


cout%26lt;%26lt;" ";


cout%26lt;%26lt;"ENTER TYPE OF ACCOUNT SAVING(s)/CURRENT(c) :: ";


cin%26gt;%26gt;type;


cout%26lt;%26lt;" ";


cout%26lt;%26lt;"ENTER INITIAL AMOUNT ::Rs ";cin%26gt;%26gt;deposit;


cout%26lt;%26lt;" ";


}


void withdrawal(int m)


{


cout%26lt;%26lt;"AMOUNT BEFORE WITHDRAWING::Rs "%26lt;%26lt;deposit%26lt;%26lt;"";


deposit=deposit-m;


cout%26lt;%26lt;"AMOUNT AFTER WITHDRAWING::Rs "%26lt;%26lt;deposit;


}


void deposital(int m)


{


cout%26lt;%26lt;"AMOUNT BEFORE DEPOSIT::Rs "%26lt;%26lt;deposit%26lt;%26lt;"";


deposit=deposit+m;


cout%26lt;%26lt;"AMOUNT AFTER DEPOSIT ::Rs "%26lt;%26lt;deposit;


}


void dispdata()


{


int scrnt=0;


if(scrnt==1)


{


clrscr();


cout%26lt;%26lt;"DISPLAY ALL MENU ";


scrnt=0;


}


cout%26lt;%26lt;"





ACCOUNT NUMBER ::";


cout%26lt;%26lt;accountno;


cout%26lt;%26lt;"NAME OF DEPOSITER ::";


cout%26lt;%26lt;name;


cout%26lt;%26lt;"TYPE OF ACCOUNT SAVING(s)/CURRENT(c) :: ";


cout%26lt;%26lt;type;


cout%26lt;%26lt;"BALANCE ::Rs ";


cout%26lt;%26lt;deposit;


scrnt++;


}


};





void main()


{


int menuch;


do


{


clrscr();


textcolor(14);


textbackground(1);


cout%26lt;%26lt;"MAIN MENU ";


cout%26lt;%26lt;"


1.NEW ACCOUNT ";


cout%26lt;%26lt;"


2.CLOSE AN ACCOUNT ";


cout%26lt;%26lt;"


3.MODIFY AN ACCOUNT ";


cout%26lt;%26lt;"


4.DISPLAY AN ACCOUNT ";


cout%26lt;%26lt;"


5.DISPLAY ALL RECORDS ";


cout%26lt;%26lt;"


6.WITHDRAW AMOUNT";


cout%26lt;%26lt;"


7.DEPOSIT AMOUNT";


cout%26lt;%26lt;"


8.EXIT ";


cout%26lt;%26lt;"


ENTER YOUR CHOICE ";


cin%26gt;%26gt;menuch;





switch(menuch)


{





case 1:addrecord();break;


case 2:delrecord();break;


case 3:modrecord();break;


case 4:disprecord();break;


case 5:dispall();break;


case 6:withdraw();break;


case 7:deposit();break;


}


}


while(menuch!=8);


}


void addrecord()


{


account obj_1,obj_2;


fstream fout;


fout.open("banking.txt",ios::in|ios::bin...


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


int recsize=sizeof(account);


fout.seekg(0,ios::end);


fout.seekg(-1*recsize,ios::cur);


fout.read((char*)%26amp;obj_1,recsize);


int mrno=obj_1.giveaccountno();


fout.close();


clrscr();


cout%26lt;%26lt;"ADD MENU





";


obj_2.getdata(mrno);


fout.open("banking.txt",ios::app|ios::bi...


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


fout.write((char*)%26amp;obj_2,recsize);


cout%26lt;%26lt;"





RECORD ADDED TO DATABASE"%26lt;%26lt;"


Press any key to


continue... ";


getch();


fout.close();


}


void dispall()


{


account obj_3;


fstream fout;


int recsize=sizeof(account);


int countrec=0;


clrscr();


cout%26lt;%26lt;"


DISPLAY ALL MENU


";


fout.open("banking.txt",ios::in);


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


while(fout.read((char*)%26amp;obj_3,recsize))


{


obj_3.dispdata();


countrec++;


cout%26lt;%26lt;"


PRESS ANY KEY FOR NEXT....";


getch();


}


clrscr();


cout%26lt;%26lt;"





END OF FILE.TOTALNUMBER OF RECORDS..."%26lt;%26lt;countrec;


cout%26lt;%26lt;"





Press any key......";


getch();


fout.close();}


void disprecord()


{


account obj_4;


fstream fout;


int mrno,flag=0;


int recsize=sizeof(account);


clrscr();


cout%26lt;%26lt;"


DISPLAY A RECORD MENU


";


fout.open("banking.txt",ios::in);


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


cout%26lt;%26lt;"





ENTER THE ACCOUNT NUMBER ";cin%26gt;%26gt;mrno;


while(fout.read((char*)%26amp;obj_4,recsize))


{


if (obj_4.giveaccountno()==mrno)


{


obj_4.dispdata();


cout%26lt;%26lt;"





Press any key.....";


flag=1;break;


}


}


if(flag==0)


{


cout%26lt;%26lt;"





NO SUCH ACCOUNT EXIST ";


cout%26lt;%26lt;"





Press any key......";


}


getch();


fout.close();


}


void delrecord()


{


account obj_5;


fstream fout,temp;


int mrno,flag;


int recsize=sizeof(account);


clrscr();


cout%26lt;%26lt;"





CLOSE ACCOUNT MENU


";


fout.open("banking.txt",ios::in);


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";


getch();


return;


}


temp.open("temp.txt",ios::app|ios::binar...


if(!temp)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";


getch();


return;


}


cout%26lt;%26lt;"





ENTER THE ACCOUNT NUMBER ";


cin%26gt;%26gt;mrno;


while(fout.read((char*)%26amp;obj_5,recsize))


{


if(obj_5.giveaccountno()==mrno)


{


obj_5.dispdata();


char confirm;


cout%26lt;%26lt;"





ARE YOU SURE TO DELETE IT(Y/N)..";cin%26gt;%26gt;confirm;


if(confirm=='Y'||confirm=='y')


{


fout.read((char*)%26amp;obj_5,recsize);


cout%26lt;%26lt;"





RECORD DELETED FORM DATABASE


";


cout%26lt;%26lt;"press any key....";


flag=1;


if(!fout)


break;


}


flag=1;


}


temp.write((char*)%26amp;obj_5,recsize);}


fout.close();


temp.close();


remove("banking.txt");


rename("temp.txt","banking.txt");


if(flag==0)


{


cout%26lt;%26lt;"





NO SUCH ACCOUNT EXIST";


cout%26lt;%26lt;"Press any key.....";


}


getch();


}


void modrecord()


{


account obj_6;


fstream fout;


int mrno,flag=0;


int recsize=sizeof(account);


clrscr();


cout%26lt;%26lt;"


MODIFY RECORD MENU


";


fout.open("banking.txt",ios::in|ios::out...


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";


getch();


return;


}


fout.seekg(ios::beg);


cout%26lt;%26lt;"


ENTER RECORD NUMBER ";


cin%26gt;%26gt;mrno;


while(fout.read((char*)%26amp;obj_6,recsize))


{


if(obj_6.giveaccountno()==mrno)


{


clrscr();


cout%26lt;%26lt;"





MODIFY MENU





";


obj_6.dispdata();


int tmprno=obj_6.giveaccountno()-1;


account obj_7;


cout%26lt;%26lt;"





ENTER NEW DATA


";


obj_7.getdata(tmprno);


char confirm;


cout%26lt;%26lt;"





ARE YOU SURE(Y/N)


";


cin%26gt;%26gt;confirm;


if(confirm=='Y'||confirm=='y')


{


fout.seekg(-1*recsize,ios::cur);


fout.write((char*)%26amp;obj_7,recsize);


cout%26lt;%26lt;"





RECORD MODIFIED


";


cout%26lt;%26lt;"Press any key.....";


flag=1;


}


}


if(flag==0)


{


cout%26lt;%26lt;"NO SUCH RECORD EXIST


";


cout%26lt;%26lt;"Press any key.....";


}


}


fout.close();


getch();


}


void withdraw()


{


account obj_9;


fstream fout;


int mrno=0;


int recsize=sizeof(account);


clrscr();


cout%26lt;%26lt;"





WITHDRAWAL MENU


";


fout.open("banking.txt",ios::in|ios::out...


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


fout.seekg(ios::beg);


cout%26lt;%26lt;"


ENTER ACCOUNT NUMBER ";


cin%26gt;%26gt;mrno;


while(fout.read((char*)%26amp;obj_9,recsize))


{


if(obj_9.giveaccountno()==mrno)


{


clrscr();


cout%26lt;%26lt;"


ENTER THE AMOUNT TO BE WITHDRAWED::Rs ";


cin%26gt;%26gt;w;


obj_9.withdrawal(w);


fout.seekg(-1*recsize,ios::cur);


fout.write((char*)%26amp;obj_9,recsize);


}


}


fout.close();


getch();


}








void deposit(void)


{


account obj_10;


fstream fout;


int mrno=0;


int recsize=sizeof(account);


clrscr();


cout%26lt;%26lt;"





DEPOSITAL MENU


";


fout.open("banking.txt",ios::in|ios::out...


if(!fout)


{


cout%26lt;%26lt;"FILE OPEN ERROR ";getch();return;}


fout.seekg(ios::beg);


cout%26lt;%26lt;"


ENTER ACCOUNT NUMBER ";


cin%26gt;%26gt;mrno;


while(fout.read((char*)%26amp;obj_10,recsize))


{


if(obj_10.giveaccountno()==mrno)


{


clrscr();


cout%26lt;%26lt;"


ENTER THE AMOUNT TO BE DEPOSITED::Rs ";


cin%26gt;%26gt;w;


obj_10.deposital(w);


fout.seekg(-1*recsize,ios::cur);


fout.write((char*)%26amp;obj_10,recsize);


}


} fout.close();


getch();


}

Help for computer c++ project banking?
Need For Computerisation


1. To Save Time


2. To Achive Accuracy


3. To Save Space(which is wasted in traditional manul/file based system).


4. Easy Retrival/Modification


5.To Enhance Transparency


6. To minimize frauds


7. Many Drawback of Current System


8. Redundancy


9. Problems with backup in case of acidents like fire, flood, earth quack. Computer Memory ca neasliy be restored or shifted from oe place to another in short span of time.


............................ etc





Future Enhancemetn Like





1. Online/Internet Banking


2. Linking with ATM's


3. Mobile Banking
Reply:wat bout networking and security
Reply:That is too much of work, you may contact a C++ expert at http://askexpert.info/ to help you finish your assignment.
Reply:Need for computerisation:





It is actually a great research topic. It is actually for error free and workflow-driven systematic process.





Improvements:





Friendly click-n-pick GUI.


Can any ont temm me why the following source code of mine in c++ is not worlin??

# include%26lt;dos.h%26gt;


# include%26lt;conio.h%26gt;


# include%26lt;stdio.h%26gt;


# include%26lt;ctype.h%26gt;


# include%26lt;string.h%26gt;


# include%26lt;iomanip.h%26gt;


# include%26lt;fstream.h%26gt;


# include%26lt;iostream.h%26gt;


# include%26lt;graphics.h%26gt;


# include%26lt;math.h%26gt;


# define p 240





char strin[20];


//following functions are used by the programmer to


//edit,append,delete data using progmammer function


//which can be accessed by pass function.


void pass(void);


void edit(void);


void append(void);


void recshow(void);


void dodelete(void);


void programmer(void);





//structure declaration to store names of


//trains and attractions.


struct arr{ char name[5][20]; };


struct tr { char names[2][20]; };


//declaration of class TOUR


class TOUR{


private:


char destination[20];


char state[20];


char season[20];


char cost[20];


tr trains;


tr timings;


arr attractions;


tr hotels;


char type[20];


char sp[160];


public:


void read_data(void);


void show_data(void);


int compare(char string[20])


{


if (strcmp(destination,string)==0)


return 1;


else


return 0;


}


void give_destination()


{


strcpy(strin,destination);}


}


//globally defined objects for class TOUR.


twork,worker;


//function used in the program to hold the screen


void wait(void)


{


cout%26lt;%26lt;"\nPRESS ANY KEY TO CONINUE \n";


getch();


}


//public function of class TOUR which reads data input by the programmer


void TOUR::read_data()


{


clrscr();


int blank,x,i,j,l;


cout%26lt;%26lt;"\n-------------------------------... DATA------------";


cout%26lt;%26lt;"---------------------- \n";


cout%26lt;%26lt;"DESTINATION "; gets(destination);


l=strlen(destination);


for (j=0;j%26lt;=l;j++)


destination[j]=toupper(destination[j])...


blank=20-strlen(destination);


for(x=1;x%26lt;=blank;x++)


strcat(destination," ");


destination[19]='\0';





cout%26lt;%26lt;"STATE "; gets(state);


l=strlen(state);


for(j=0;j%26lt;=l;j++)


state[j]=toupper(state[j]);


blank=20-strlen(state);


for (x=1;x%26lt;=blank;x++)


strcat(state," ");


state[19]='\0';





cout%26lt;%26lt;"SEASON "; gets(season);


l=strlen(season);


for(j=0;j%26lt;=l;j++)


season[j]=toupper(season[j]);


blank=20-strlen(season);


for(x=1;x%26lt;=blank;x++)


strcat(season," ");


season[19]='\0';





cout%26lt;%26lt;"COST "; gets(cost);


l=strlen(cost);


for(j=0;j%26lt;=l;j++)


cost[j]=toupper(cost[j]);


blank=20-strlen(cost);


for(x=1;x%26lt;=blank;x++)


strcat(cost," ");


cost[19]='\0';





cout%26lt;%26lt;"TRAINS ";


for (j=0;j%26lt;2;j++)


{


gets(trains.names[j]);


l=strlen(trains.names[j]);


for(i=0;i%26lt;=l;i++)


trains.names[j][i]=toupper(trains.names[...


blank=20-strlen(trains.names[j]);


for(x=1;x%26lt;=blank;x++)


strcat(trains.names[j]," ");


trains.names[j][19]='\0';


}





cout%26lt;%26lt;"TIMINGS ";


for (j=0;j%26lt;2;j++)


{


gets(timings.names[j]);


l=strlen(timings.names[j]);


for(i=0;i%26lt;=l;i++)


timings.names[j][i]=toupper(timings.name...


blank=20-strlen(timings.names[j]);


for(x=1;x%26lt;=blank;x++)


strcat(timings.names[j]," ");


timings.names[j][19]='\0';


}





cout%26lt;%26lt;"ATRRACTIONS ";


for(i=0;i%26lt;5;i++)


{


gets(attractions.name[i]);


l=strlen(attractions.name[i]);


for(j=0;j%26lt;=l;j++)


attractions.name[i][j]=toupper(attractio...


blank=20-strlen(attractions.name[i]);


for(x=1;x%26lt;=blank;x++)


strcat(attractions.name[i]," ");


attractions.name[i][19]='\0';


}





cout%26lt;%26lt;"HOTELS ";


for (j=0;j%26lt;2;j++)


{


gets(hotels.names[j]);


l=strlen(hotels.names[j]);


for(i=0;i%26lt;=l;i++)


hotels.names[j][i]=toupper(hotels.names[...


blank=20-strlen(hotels.names[j]);


for(x=1;x%26lt;=blank;x++)


strcat(hotels.names[j]," ");


hotels.names[j][19]='\0';


}





cout%26lt;%26lt;"TYPE "; gets(type);


l=strlen(type);


for(j=0;j%26lt;=l;j++)


type[j]=toupper(type[j]);


blank=20-strlen(type);


for(x=1;x%26lt;=blank;x++)


strcat(type," ");


type[19]='\0';





cout%26lt;%26lt;"SPECIALITY "; gets(sp);


l=strlen(sp);


for(j=0;j%26lt;=l;j++)


sp[j]=toupper(sp[j]);


blank=20-strlen(sp);


for(x=1;x%26lt;=blank;x++)


strcat(sp," ");


sp[159]='\0';


}


//public function of class TOUR which displays data on the screen


void TOUR::show_data()


{


clrscr();


cout%26lt;%26lt;"\n*************************VARI... TOURIST PLACES ARE AS***";


cout%26lt;%26lt;"************************\n";


cout%26lt;%26lt;endl;


cout%26lt;%26lt;endl%26lt;%26lt;"DESTINATION--%26gt; "%26lt;%26lt;destination%26lt;%26lt;" STATE-----%26gt; "%26lt;%26lt;state;


cout%26lt;%26lt;endl%26lt;%26lt;"SEASON-------%26gt; "%26lt;%26lt;season%26lt;%26lt;" COST------%26gt; "%26lt;%26lt;cost;


cout%26lt;%26lt;endl%26lt;%26lt;"TRAINS-------%26gt; "%26lt;%26lt;trains.names[0]%26lt;%26lt;" TIMINGS---%26gt; "


%26lt;%26lt;timings.names[0];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;trains.names[1]%26lt;%26lt;" "


%26lt;%26lt;timings.names[1];


cout%26lt;%26lt;endl%26lt;%26lt;"ATTRACTIONS--%26gt; "%26lt;%26lt;attractions.name[0]%26lt;%26lt;" HOTELS----%26gt; "


%26lt;%26lt;hotels.names[0];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attractions.name[1]%26lt;%26lt;" "


%26lt;%26lt;hotels.names[1];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attractions.name[2]%26lt;%26lt;" TYPE------%26gt; "


%26lt;%26lt;type;


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attractions.name[3];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attractions.name[4];


cout%26lt;%26lt;endl%26lt;%26lt;endl%26lt;%26lt;sp;


cout%26lt;%26lt;endl%26lt;%26lt;endl;


cout%26lt;%26lt;"\n*****************************...


cout%26lt;%26lt;"***********************\n";


wait();


}





void recshow()


{


clrscr();


fstream tfile("tourism.dat",ios::binary|ios::out...


cout%26lt;%26lt;"CONTENTS OF FILE ARE AS\n";


tfile.seekg(0,ios::beg);


tfile.read((char*)%26amp;worker,sizeof(TOUR));


while (!tfile.eof())


{


worker.show_data();


tfile.read((char*)%26amp;worker,sizeof(TOUR));


}


tfile.close();


cout%26lt;%26lt;" DESIRED RECORD(S) ARE DISLPLAYED \n";


}





void append()


{


clrscr();


char ch;


int recno;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::end);


recno=tfile.tellg()/sizeof(TOUR);


cout%26lt;%26lt;"\n NO OF RECORDS IN FILE ARE AS "%26lt;%26lt;recno%26lt;%26lt;endl;


do


{ cout%26lt;%26lt;"\n WANT TO ENTER MORE DATA Y/N \n";


ch=toupper(getche());


if (ch=='Y')


{


cout%26lt;%26lt;"\n RECORD NUMBER "%26lt;%26lt;recno+1%26lt;%26lt;endl;


twork.read_data();


twork.give_destination();


cout%26lt;%26lt;"\n YOUR DESTINATION WAS "%26lt;%26lt;strin%26lt;%26lt;endl;


tfile.seekg(0,ios::beg);


int found=0;


while (!tfile.eof()%26amp;%26amp;!found)


{


tfile.read((char*)%26amp;worker,sizeof(TOUR));


if (worker.compare(strin))


found=1;


}


if (!found)


{


tfile.clear();


recno++;


tfile.seekp(0,ios::end);


tfile.write((char*)%26amp;twork,sizeof (TOUR));


cout%26lt;%26lt;" \nNEW RECORD IS ENTERED SUCCESFULLY\n";


}


else


{


cout%26lt;%26lt;" !!! THIS DESTINATION ALREADY EXISTS !!!\n";


wait();


recshow();


}


}


}


while(ch=='Y');


tfile.close();


}





void edit()


{


fstream tfile("tourism.dat",ios::binary|ios::in|...


cout%26lt;%26lt;"ENTER DESTINATION FOR WHICH YOU WANT TO EDIT RECORD \n";


gets(strin);


int l=strlen(strin);


for (int j=0;j%26lt;=l;j++)


strin[j]=toupper(strin[j]);


int blank=20-strlen(strin);


for(int x=1;x%26lt;blank;x++)


strcat(strin," ");


strin[19]='\0';


int found=0;


while (!tfile.eof() %26amp;%26amp; !found)


{


tfile.read((char*)%26amp;worker,sizeof(TOUR));


if (worker.compare(strin))


found=1;


}


if(!found)


cout%26lt;%26lt;"\n NO RECORD FOUND FOUND IN THIS DESTINATION\n";


else


{


worker.show_data();


worker.read_data();


tfile.seekp(tfile.tellp()-sizeof(worker)...


tfile.write((char*)%26amp;worker,sizeof(TOUR))...


cout%26lt;%26lt;" EDITED RECORD IS SAVED SUCCESSFULLY \n";


}


wait();


tfile.close();


}





void dodelete()


{


fstream tfile ("tourism.dat",ios::binary|ios::out|ios:...


int found=0;


char ok;


cout%26lt;%26lt;"\n ENTER DESTINATION TO DELETE THE RECORD\n";


gets(strin);


int l=strlen(strin);


for (int j=0;j%26lt;=l;j++)


strin[j]=toupper(strin[j]);


int blank=20-strlen(strin);


for(int x=1;x%26lt;blank;x++)


strcat(strin," ");


strin[19]='\0';


while (!tfile.eof()%26amp;%26amp;!found)


{


tfile.read((char*)%26amp;worker,sizeof(worker)...


if(worker.compare(strin))


found=1;


}


if(!found)


{


cout%26lt;%26lt;"\n NO SUCH RECORD FOUND\n";


wait();


}


else


{


recshow();


cout%26lt;%26lt;"\nWANT TO DELETE THIS RECORD Y/N \n";


ok=toupper(getche());


if(ok=='Y')


{


fstream mtemp("temp.dat",ios::binary|ios::in|ios...


tfile.seekg(ios::beg);


tfile.read((char*)%26amp;worker,sizeof(worker)...


tfile.clear();


while(!tfile.eof())


{


if(!worker.compare(strin))


mtemp.write((char*)%26amp;worker,sizeof(worker...


tfile.read((char*)%26amp;worker,sizeof(worker)...


}


tfile.close();


mtemp.close();


remove("tourism.dat");


if (rename("temp.dat","tourism.dat")==0)


cout%26lt;%26lt;"\nêêê RECORD IS DELETED SUCCESSFULLY êêê\n";


else


cout%26lt;%26lt;"\n!!!OPERATION IS UNSUCCESSFUL!!!\n";


wait();


}


}


}





void pass()


{


clrscr();


clearviewport();


int c=0,y=0;


char pass_word[20];


const char password[]={"210785"};


while(c%26lt;2)


{


c++;


setbkcolor(BLUE);


for (y=1;y%26lt;14;y++)


cout %26lt;%26lt; endl;


cout %26lt;%26lt; "\t\têêê ENTER YOUR PASSWORD êêê\n";


gotoxy(50,14);


gets(pass_word);


if(strcmp(password,pass_word)==0)


{


programmer();


break;


}


else


cout%26lt;%26lt;"ëëë BAD LUCK PASSWORD IS WRONG ëëë";


if (c%26lt;2)


//textattr(RED+BLINK);


//cprintf("\n²²² TRY ONCE MORE ²²²\r\n");


cprintf("\n²²² TRY ONCE MORE ²²²\r\n");


}


wait();


}





void programmer(void)


{


//setbkcolor(BLUE);


// textbackground(BLUE);


int ok,y;


do {


clrscr();


clearviewport();


setbkcolor(BLUE);





for(y=1;y%26lt;=3;y++)


cout%26lt;%26lt;"\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\t ";


cout%26lt;%26lt;"ENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\t\tAPPEND RECORD ---%26gt; 1 \t\t\t\t";


cout%26lt;%26lt;"\t\t\t\tEDIT RECORD ---%26gt; 2 \t\t\t\t";


cout%26lt;%26lt;"\t\t\t\tDELETE RECORD ---%26gt; 3 \t\t\t\t";


cout%26lt;%26lt;"\t\t\t\tSHOW RECORD ---%26gt; 4 \t\t\t\t";


cout%26lt;%26lt;"\t\t\t\tEXIT ---%26gt; 5 \t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=0;y%26lt;20;y++)


cout%26lt;%26lt;"\t\t\t\t\t ";


cout %26lt;%26lt; "\t\t\t\t Enter choice : ";


cin%26gt;%26gt;ok;





switch(ok)


{


case 1:append();


break;


case 2: edit();


break;


case 3: dodelete();


break;


case 4: recshow();


break;


case 5:break;


default:cout%26lt;%26lt;" INVALID CHOICE \n";delay(1500);break;


}


} while(ok!=5);


}


//class which acssess the data


class TRAVEL { private:


char dest[20];


char st[20];


char seas[20];


char ct[20];


tr tra;


tr timing;


arr attract;


tr hotel;


char ty[20];


char special[160];


public:


void get_state(char tt[20]);


void get_attract(char tt[20]);


void get_read();


void get_alpha(char tt[20]);


void get_all(char tt[20]);


void get_dest(char tt[20]);


void get_season(char tt[20]);


void get_cost(char tt[20]);


void dest_seas();


void seas_state();


void state_cost();


void all();


} abc,pqr;


//member function of class TRAVEL which acssess the data.


void TRAVEL::get_read()


{


clrscr();


cout%26lt;%26lt;"\n*************************VARI... TOURIST PLACES ARE AS***";


cout%26lt;%26lt;"************************\n";


cout%26lt;%26lt;endl;


cout%26lt;%26lt;endl%26lt;%26lt;"DESTINATION--%26gt; "%26lt;%26lt;dest%26lt;%26lt;" STATE-----%26gt; "%26lt;%26lt;st;


cout%26lt;%26lt;endl%26lt;%26lt;"SEASON-------%26gt; "%26lt;%26lt;seas%26lt;%26lt;" COST------%26gt; "%26lt;%26lt;ct;


cout%26lt;%26lt;endl%26lt;%26lt;"TRAINS-------%26gt; "%26lt;%26lt;tra.names[0]%26lt;%26lt;" TIMINGS---%26gt; "


%26lt;%26lt;timing.names[0];





cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;tra.names[1]%26lt;%26lt;" "


%26lt;%26lt;timing.names[1];


cout%26lt;%26lt;endl%26lt;%26lt;"ATTRACTIONS--%26gt; "%26lt;%26lt;attract.name[0]%26lt;%26lt;" HOTELS----%26gt; "


%26lt;%26lt;hotel.names[0];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attract.name[1]%26lt;%26lt;" "


%26lt;%26lt;hotel.names[1];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attract.name[2];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attract.name[3];


cout%26lt;%26lt;endl%26lt;%26lt;" "%26lt;%26lt;attract.name[4];


cout%26lt;%26lt;endl%26lt;%26lt;endl%26lt;%26lt;special;


cout%26lt;%26lt;endl;


cout%26lt;%26lt;"\n*****************************...


cout%26lt;%26lt;"************************\n";


wait();


}


//member function of class TRAVEL which compares destination and season


//input by the user and displays data corresponding to the same.


void TRAVEL::dest_seas()


{


char ch,destination[20],season[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER DESTINATION %26amp; SEASON FOR WHICH INFORMATION IS TO BE";


cout%26lt;%26lt;" DISPLAYED\n";


cout%26lt;%26lt;"DESTINATION "; gets(destination);


cout%26lt;%26lt;"SEASON ";gets(season);


int l=strlen(destination);


for (int j=0;j%26lt;=l;j++)


destination[j]=toupper(destination[j])...


int blank=20-strlen(destination);


for(int x=1;x%26lt;blank;x++)


strcat(destination," ");


destination[19]='\0';


l=strlen(season);


for (j=0;j%26lt;=l;j++)


season[j]=toupper(season[j]);


blank=20-strlen(season);


for(x=1;x%26lt;blank;x++)


strcat(season," ");


season[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;destination%26lt;%26lt;"%26amp; "%26lt;%26lt;season%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(dest,destination)==0)%26amp;%26amp;(strcmp(...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;destination%26lt;%26lt;"%26amp; "%26lt;%26lt;season%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares the state and cost


//input by the user and displays the data corresonding to the same.


void TRAVEL::state_cost()


{


char ch,state[20],cost[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER STATE %26amp; COST RANGE FOR WHICH ";


cout%26lt;%26lt;"INFORMATION IS TO BE DISPLAYED\n";


cout%26lt;%26lt;"STATE "; gets(state);


cout%26lt;%26lt;"COST RANGE ";gets(cost);


int l=strlen(state);


for (int j=0;j%26lt;=l;j++)


state[j]=toupper(state[j]);


int blank=20-strlen(state);


for(int x=1;x%26lt;blank;x++)


strcat(state," ");


state[19]='\0';


blank=20-strlen(cost);


for(x=1;x%26lt;blank;x++)


strcat(cost," ");


cost[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;state%26lt;%26lt;"%26amp; "%26lt;%26lt;cost%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(st,state)==0)%26amp;%26amp;(strcmp(ct,cost)...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;state%26lt;%26lt;"%26amp; "%26lt;%26lt;cost%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\nHAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares the season and state


//input by the user and displays data corresponding to the same.


void TRAVEL::seas_state()


{


char ch,state[20],season[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER STATE %26amp; SEASON FOR WHICH INFORMATION IS TO BE DISPLAYED\n";


cout%26lt;%26lt;"STATE "; gets(state);


cout%26lt;%26lt;"SEASON ";gets(season);


int l=strlen(state);


for (int j=0;j%26lt;=l;j++)


state[j]=toupper(state[j]);


int blank=20-strlen(state);


for(int x=1;x%26lt;blank;x++)


strcat(state," ");


state[19]='\0';


l=strlen(season);


for (j=0;j%26lt;=l;j++)


season[j]=toupper(season[j]);


blank=20-strlen(season);


for(x=1;x%26lt;blank;x++)


strcat(season," ");


season[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;state%26lt;%26lt;"%26amp; "%26lt;%26lt;season%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(st,state)==0)%26amp;%26amp;(strcmp(seas,sea...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;state%26lt;%26lt;"%26amp; "%26lt;%26lt;season%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\nHAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which displays the entire data of the file.


void TRAVEL::all()


{


char ch;


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"WANT TO SEE ALL RECORD Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while(!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


i++;


abc.get_read();


cout%26lt;%26lt;"WANT TO SEE MORE RECORDS Y/N \n";


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND";


else


cout%26lt;%26lt;"\nHAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares state input by the user and


//displays data corresponding to same.


void TRAVEL::get_state(char tt[20])


{


char ch,state[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER STATE FOR WHICH INFORMATION IS TO BE DISPLAYED\n";


gets(state);


int l= strlen(state);


for (int j=0;j%26lt;=l;j++)


state[j]=toupper(state[j]);


int blank=20-strlen(state);


for(int x=1;x%26lt;blank;x++)


strcat(state," ");


state[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;state%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(st,state)==0)%26amp;%26amp;(strcmp(ty,tt)==...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;state%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares attractions


//input by the user and displays data corresponding to same.


void TRAVEL::get_attract(char tt[20])


{


char ch,attraction[20],att[20];


int i=0,j=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER ATTRACTION/NAME OF TEMPLE OR MOSQUE/NAME OF GOD/FESTIVALS";


cout%26lt;%26lt;"/FORTS AND PALACES FOR WHICH INFORMATION IS TO BE DISPLAYED\n";


gets(attraction);


int l=strlen(attraction);


for (j=0;j%26lt;=l;j++)


attraction[j]=toupper(attraction[j]);


int blank=20-strlen(attraction);


for(int x=1;x%26lt;=blank;x++)


strcat(attraction," ");


attraction[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;attraction%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


for (j=0;j%26lt;5;j++)


{


strcpy(att,attract.name[j]);


if ((strcmp(att,attraction)==0)%26amp;%26amp;(strcmp(ty...


{


abc.get_read();


i++;


}


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if (i==0)


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;attraction%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares type


//chosen by the user and displays all data for the same.


void TRAVEL::get_all(char tt[20])


{


char ch;


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"WANT ALL DESTINATIONS TO BE DISPLAYED Y/N \n"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if (strcmp(ty,tt)==0)


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if (i==0)


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;tt%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares cost range input by the


//user and displays data corresponding to the same.


void TRAVEL::get_cost(char tt[20])


{


char ch,cost[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER COST RANGE FOR WHICH INFORMATION IS TO BE DISPLAYED\n";


gets(cost);


int l=strlen(cost);


for (i=0;i%26lt;=l;i++)


strcat(cost," ");


cost[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;cost%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(ct,cost)==0)%26amp;%26amp;(strcmp(ty,tt)==0...


{


abc.get_read();


i++;


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if ((i==0)%26amp;%26amp;(ch=='Y'))


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;cost%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares season input by the user


//and displays data corresponding to the same.


void TRAVEL::get_season(char tt[20])


{


char ch,season[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER SEASON SUCH AS OCTOBER TO NOVEMBER FOR WHICH INFORMATION";


cout%26lt;%26lt;"IS TO BE DISPLAYED \n";


gets(season);


int l=strlen(season);


for(int j=0;j%26lt;=l;j++)


season[j]=toupper(season[j]);


int blank=20-strlen(season);


for(int x=1;x%26lt;blank;x++)


strcat(season," ");


season[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;season%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(seas,season)==0)%26amp;%26amp;(strcmp(ty,tt...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if (i==0)


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;season%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares destination input by the


//user and displays data corresponding to that.


void TRAVEL::get_dest(char tt[20])


{


char ch,destination[20];


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER DESTINATION FOR WHICH INFORMATION IS TO BE DISPLAYED \n";


gets(destination);


int l=strlen(destination);


for(int j=0;j%26lt;=l;j++)


destination[j]=toupper(destination[j])...


int blank=20-strlen(destination);


for (int x=1;x%26lt;blank;x++)


strcat(destination," ");


destination[19]='\0';


cout%26lt;%26lt;"WANT TO FIND RECORD FOR "%26lt;%26lt;destination%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if ((strcmp(dest,destination)==0)%26amp;%26amp;(strcmp(...


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if (i==0)


cout%26lt;%26lt;"\n !!!NO RECORD FOUND FOR "%26lt;%26lt;destination%26lt;%26lt;"!!!"%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//member function of class TRAVEL which compares alphabet input by the user


//and displays data starting from same.


void TRAVEL::get_alpha(char tt[20])


{


char ch,alpha;


int i=0;


fstream tfile("tourism.dat",ios::binary|ios::in|...


tfile.seekg(0,ios::beg);


cout%26lt;%26lt;"ENTER ALPHABET FOR WHICH INFORMATION IS TO BE DISPLAYED \n";


alpha=toupper(getche());


cout%26lt;%26lt;"\n WANT TO FIND RECORD STARTING FROM "%26lt;%26lt;alpha%26lt;%26lt;" Y/N"%26lt;%26lt;endl;


ch=toupper(getch());


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


while (!(tfile.eof())%26amp;%26amp;(ch=='Y'))


{


if((alpha==dest[0])%26amp;%26amp;(strcmp(ty,tt)==0))


{


i++;


abc.get_read();


}


tfile.read((char*)%26amp;abc,sizeof(TRAVEL));


}


tfile.close();


if (i==0)


cout%26lt;%26lt;"\n NO RECORD FOUND FOR "%26lt;%26lt;alpha%26lt;%26lt;endl;


else


cout%26lt;%26lt;"\n HAVE A GOOD DAY \n";


wait();


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE HILL STATIONS.


void hill()


{


int ok,blank,y;


char type[20]={"HILL STATION" };


blank=20-strlen(type);


for(int i=1;i%26lt;=blank;i++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for (y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER \t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION----%26gt; 1 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY-----%26gt; 2 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET--%26gt; 3 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE-------------%26gt; 4 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tSEASON-----------------%26gt; 5 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL HILL STATIONS------%26gt; 6 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tPARTICULAR ATTRACTION--%26gt; 7 \t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-------------------%26gt; 8 \t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for (y=1;y%26lt;12;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout %26lt;%26lt; "\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1: abc.get_dest(type);


break;


case 2: abc.get_state(type);


break;


case 3: abc.get_alpha(type);


break;


case 4: abc.get_cost(type);


break;


case 5: abc.get_season(type);


break;


case 6: abc.get_all(type);


break;


case 7: abc.get_attract(type);


break;


case 8: break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=8);


}


// FUNCTION TO BE CALLED WHEN USER CHOOSES TO SEE SOUTHERN DESTINATIONS.


void south()


{


int ok,y;


char type[20]={"SOUTH"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout%26lt;%26lt;"\t ENTER CHOICE %26amp; PRESS ENTER\t\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t NAME OF DESTINATION-----------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t STATE WISE DISPLAY------------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t A PARTICULAR ALPHABET---------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t COST RANGE--------------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t SEASON------------------------%26gt; 5\t\t\t\t";


cout%26lt;%26lt;"\t ALL SOUTHERN DESTINATIONS-----%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t FESTIVALS OF SOUTH------------%26gt; 7\t\t\t\t";


cout%26lt;%26lt;"\t EXIT--------------------------%26gt; 8\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;12;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t Enter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1: abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_season(type);


break;


case 6:abc.get_all(type);


break;


case 7:abc.get_attract(type);


break;


case 8: break;


default:cout%26lt;%26lt;" INVALID CHOICE \n";delay(1500);break;


}


}


while(ok!=8);


}


//FUNCTION TO BE CALLED WHEN USER CHOOSES TO SEE RELIGIOUS PLACES.


void religion()


{


int ok,y;


char type[20]={"RELIGIOUS"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout%26lt;%26lt;"\t\t\tENTER CHOICE AND PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION----%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY-----%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET--%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE-------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSEASON-----------------%26gt; 5\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL RELIGIOUS PLACES---%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t\t\tNAME OF GOD------------%26gt; 7\t\t\t\t";


cout%26lt;%26lt;"\t\t\tNAME OF TEMPLE/MOSQUE--%26gt; 8\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-------------------%26gt; 9\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;12;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_season(type);


break;


case 6:abc.get_all(type);


break;


case 7:abc.get_attract(type);


break;


case 8:abc.get_attract(type);


break;


case 9: break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=9);


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE SEA BEACHES.


void seas()


{


int ok,y;


char type[20]={"BEACH"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION----%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY-----%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET--%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE-------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSEASON-----------------%26gt; 5\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL BEACHES------------%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t\t\tPARTICULAR ATTRACTION--%26gt; 7\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-------------------%26gt; 8\t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;11;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout %26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_season(type);


break;


case 6:abc.get_all(type);


break;


case 7:abc.get_attract(type);


break;


case 8: break;


default:cout%26lt;%26lt;"invalid choice \n"; delay(1500); break;


}


}


while(ok!=8);


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE WILD LIFE SANCTURIES.


void sancturies()


{


int ok,y;


char type[20]={"SANCTURIES"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;


cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION---------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY----------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET-------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE------------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSEASON---------------------... 5\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL WILD LIFE SANCTURIES----%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t\t\tPARTICULAR ATTRACTION-------%26gt; 7\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-----------------------... 8\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;11;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_season(type);


break;


case 6:abc.get_all(type);


break;


case 7:abc.get_attract(type);


break;


case 8: break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=8);


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE LIST OF SHOPPING CENTRES.


void shopping()


{


int ok,y;


char type[20]={"SHOPPING"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;8;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION---------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL SHOPPING CENTRES--------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tPARTICULAR ATTRACTION-------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-----------------------... 4\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------\n";


for(y=1;y%26lt;11;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_all(type);


break;


case 3:abc.get_attract(type);


break;


case 4:


break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=4);


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE HISTORICAL PLACES.


void historical()


{


int ok,y;


char type[20]={"HISTORICAL"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION---------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY----------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET-------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE------------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL HISTORICAL PLACES-------%26gt; 5\t\t\t\t";


cout%26lt;%26lt;"\t\t\tFORTS AND PALACES-----------%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT-----------------------... 7\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;12;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_all(type);


break;


case 6:abc.get_attract(type);


break;


case 7:


break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=7);


}


//FUNCTION TO BE CALLED WHEN USER WANTS TO SEE EASTERN PLACES.


void east()


{


int ok,y;


char type[20]={"EAST"};


int blank=20-strlen(type);


for (int l=1;l%26lt;=blank;l++)


strcat(type," ");


type[19]='\0';


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tNAME OF DESTINATION---------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE WISE DISPLAY----------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tA PARTICULAR ALPHABET-------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tCOST RANGE------------------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSEASON-------------------... 5\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL EASTERN DESTINATIONS----%26gt; 6\t\t\t\t";


cout%26lt;%26lt;"\t\t\tPARTICULAR ATTRACTION-------%26gt; 7\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT---------------------... 8\t\t\t\t";


cout%26lt;%26lt;"-------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;12;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.get_dest(type);


break;


case 2:abc.get_state(type);


break;


case 3:abc.get_alpha(type);


break;


case 4:abc.get_cost(type);


break;


case 5:abc.get_season(type);


break;


case 6:abc.get_all(type);


break;


case 7:abc.get_attract(type);


break;


case 8: break;


default:cout%26lt;%26lt;"invalid choice \n";delay(1500);break;


}


}


while(ok!=8);


}


//FUNCTION TO BE CALLED WHEN USER WANTS EXTRA INFORMATION FOR ALL TYPE OF


//PLACES .


void extra(void)


{


int ok,y;


do


{


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tENTER CHOICE %26amp; PRESS ENTER\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\tDESTINATION %26amp; SEASON------%26gt; 1\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE %26amp; SEASON ------%26gt; 2\t\t\t\t";


cout%26lt;%26lt;"\t\t\tSTATE %26amp; COST ------%26gt; 3\t\t\t\t";


cout%26lt;%26lt;"\t\t\tALL ------%26gt; 4\t\t\t\t";


cout%26lt;%26lt;"\t\t\tEXIT ------%26gt; 5\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;14;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\tEnter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:abc.dest_seas();


break;


case 2:abc.seas_state();


break;


case 3:abc.state_cost();


break;


case 4:abc.all();


break;


case 5: break;


default:cout%26lt;%26lt;"Invalid Choice \n";delay(1500);break;


}


}


while(ok!=5);


}





// FUNCTION FOR THE FIRST SCREEN.


void starter()


{


clearviewport();


char s;





while(!kbhit())


{





for(int i=0;i%26lt;3;i++)


{


circle(20,20,40+5*i);


circle(618,20,40+5*i);


circle(20,458,40+5*i);


circle(618,458,40+5*i);


circle(320,20,40+5*i);


circle(320,458,40+5*i);


circle(20,240,40+5*i);


circle(618,240,40+5*i);


delay(100);


}


for(i=1;i%26lt;5;i++)


{


line(5*i-5,0,5*i-5,479);


line(0,5*i-5,639,5*i-5);


line(639-5*(i-1),0,639-5*(i-1),479);


line(0,484-5*i,639,484-5*i);


delay(100);


}





settextjustify(CENTER_TEXT,CENTER_TEXT);


for(i=2;i%26lt;=9;i++)


{


settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);


setcolor(i+6);


outtextxy(320,65+10*i,"TOURS %26amp; TRAVELS ");


delay(100);





setcolor(BLACK);


outtextxy(320,65+10*i,"TOURS %26amp; TRAVELS ");


setcolor(i+6);





settextstyle(DEFAULT_FONT,HORIZ_DIR,2);


outtextxy(320,240,"Project made by - ");


settextstyle(SMALL_FONT,HORIZ_DIR,6);


setcolor(2);


outtextxy(320,285,"Prashasti Mishra %26amp; Anuradha Dalmia ");


setcolor(i+6);





settextstyle(SMALL_FONT,HORIZ_DIR,6);


outtextxy(320,325,"A Complete Tours %26amp; Travels Management Package");


settextstyle(SMALL_FONT,HORIZ_DIR,6);


setcolor(CYAN);





outtextxy(450,380,"Press any key to continue..... ");





}


settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);


setcolor(i+5);


outtextxy(320,65+10*i,"TOURS %26amp; TRAVELS ");


delay(500);


clearviewport();


delay(100);


setcolor(WHITE);





}





//if((s=getche())%26gt;=0);


settextjustify(LEFT_TEXT,TOP_TEXT);


settextstyle(DEFAULT_FONT,HORIZ_DIR,5);


} // END OF STARTER FUNCTION








void last(void)


{


float y1,a,b,i,axisx,axisy;


int c,z=1;


long float x;


int gdriver = DETECT, gmode, errorcode;


clrscr();


initgraph(%26amp;gdriver, %26amp;gmode, "c:\\bgi");


// setbkcolor(BLACK);


for(i=0;i%26lt;=2;i+=.5)


{


for (x=-12.3662/2;x%26lt;=12.3662/2;x+=0.01745)


{


a=-i*exp(-(x*x));


b=100*a;


c=b;


y1=p+c;


putpixel(318+x*100,y1,z);


delay(1);


}


z++;


}


axisx=37;axisy=12;


for(i=.5;i%26lt;=2;i+=.5)


{


gotoxy(axisx,axisy);


axisy-=3;


sound(750*i);


delay(200);


nosound();


}


axisx=2;axisy=17;


for(i=-3;i%26lt;=3;i++)


{


gotoxy(axisx,axisy);


axisx+=12;


sound(750*i);


delay(200);


nosound();


}


settextjustify(CENTER_TEXT,CENTER_TEXT);


for(i=2;i%26lt;=9;i++)


{


settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);


setcolor(i+6);


outtextxy(320,210+25*i,"THANK YOU ");


}


getch();


} // END OF LAST FUNCTION.








//MAIN BODY OF THE PROGRAM


void main (void)


{


int ok,y;


int gdriver=DETECT,gmode,errorcode;


initgraph(%26amp;gdriver,%26amp;gmode,"");





starter();


do


{


initgraph(%26amp;gdriver,%26amp;gmode,"");


graphresult();


clrscr();


clearviewport();


setbkcolor(BLUE);


for(y=1;y%26lt;5;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\t\tENTER CHOICE\t\t\t\t\t";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


cout%26lt;%26lt;"\t\t\t HILL STATION ------%26gt; 1\n";


cout%26lt;%26lt;"\t\t\t SOUTHERN DESTINATION ------%26gt; 2\n";


cout%26lt;%26lt;"\t\t\t RELIGOUS PLACE ------%26gt; 3\n";


cout%26lt;%26lt;"\t\t\t SEA SIDE ------%26gt; 4\n";


cout%26lt;%26lt;"\t\t\t WILD LIFE SANTURIES ------%26gt; 5\n";


cout%26lt;%26lt;"\t\t\t SHOPPING CENTRES ------%26gt; 6\n";


cout%26lt;%26lt;"\t\t\t HISTORICAL PLACES ------%26gt; 7\n";


cout%26lt;%26lt;"\t\t\t EXPLORE EAST ------%26gt; 8\n";


cout%26lt;%26lt;"\t\t\t PROGRAMMER ------%26gt; 9\n";


cout%26lt;%26lt;"\t\t\t EXTRA ------%26gt; 10\n";


cout%26lt;%26lt;"\t\t\t EXIT ------%26gt; 11\n";


cout%26lt;%26lt;"---------------------------------...


cout%26lt;%26lt;"------------------------";


for(y=1;y%26lt;10;y++)


cout %26lt;%26lt; "\t\t\t\t\t\t\t\t\t " %26lt;%26lt; endl;





cout%26lt;%26lt;"\t\t\t Enter choice : ";


cin%26gt;%26gt;ok;


switch(ok)


{


case 1:hill();


break;


case 2:south();


break;


case 3:religion();


break;


case 4:seas();


break;


case 5:sancturies();


break;


case 6:shopping();


break;


case 7:historical();


break;


case 8:east();


break;


case 9:pass();


break;


case 10:extra();


break;


case 11:


break;


default:cout%26lt;%26lt;"INVALID CHOICE \n";delay(1500);break;


}


closegraph();


}


while (ok!=11);


last();


}

Can any ont temm me why the following source code of mine in c++ is not worlin??
Thats a lot of code there! Is there any chance you could narrow it down a little? Try testing each function individually - this might give you more of an idea where the problem lies.





Rawlyn.
Reply:Will u care to give the details....as in what error is it showin??
Reply:Dude I tried to comple this, and got over 400 syntax errors, please check if there are any syntax errors in your complier, and narrow this problem down, and comment the code!!
Reply:You send 1500+ lines of Borland-specific DOS code fragments (it seems, it is from some old article...) and want somebody to make from it working program?!

nobile

Sunday, May 10, 2009

[C++] Why the result of my programme is "烫烫烫烫烫烫烫烫"?

my C++ code:








#include %26lt;windows.h%26gt;


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


using namespace std;





int main()


{


char a[128]="**** the truth!";


cout%26lt;%26lt;a%26lt;%26lt;endl;





ofstream outfile("temp.txt",ios::out);


for(int i=0;i%26lt;=127;i++)


{if(a[i]!=NULL)outfile%26lt;%26lt;a[i];}


outfile.close();





char b[128];


ifstream infile("temp.txt",ios::in);


for(int j=0;j%26lt;=127;j++)


{infile%26gt;%26gt;b[i];}


cout%26lt;%26lt;b%26lt;%26lt;endl;


infile.close();





return 0;


}











result:


**** the truth!


烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫!烫烫...


烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫蘁

[C++] Why the result of my programme is "烫烫烫烫烫烫烫烫"?
Probably because of this code





for(int j=0;j%26lt;=127;j++)


{infile%26gt;%26gt;b[i];}





Your for loop increments j but in the loop you are using b[i].


i should have a value of 127 or rubbish if it is out of scope.


C++: How do you edit a character string in a different function than the one you declared it in?

The following code is C++:








#include "stdafx.h"


#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


using namespace std;





int rewriteString(char *str)


{


str = "I want to output this!";


cout %26lt;%26lt; str;


return 1;


}





void main()


{


int meaninglessInteger = 0;


char str[] = "Why am I outputting this, instead of what I want to output?";


meaninglessInteger= rewriteString(str);


cout %26lt;%26lt; str;


system("PAUSE");


}





******* ******* ******* ******* ******* ******* ******* ******* *******


The above code doesn't work. I wondered if someone could help me understand what I need to change to accomplish what I'm trying to do.


I hope the code is fairly self-explanitory: I want to declare a character string in main() and then use a function called rewriteString() to change the message contained in that character string.





What's the correct way to do this? Any help is appreciated greatly!

C++: How do you edit a character string in a different function than the one you declared it in?
just my two cents ;)





int rewriteString(char *str)


{


strcpy(str,"output");


cout %26lt;%26lt; str;


return 1;


}
Reply:Okay. There is actually a very simple explanation to your answer. Once i tell you, you'll wonder why you didnt think of this in the first place.





Now, from basic C++ programming, you'd know this simple example:





void foo( int f ) { f = 25; }


void main() { int a = 10; foo(a); cout %26lt;%26lt; a; }





Now what do you think will be the output. Correct, it will be 10.


Why? Because the argument f to function foo was "passed by value" variable 'a' never changes its value. Now... just extending this to character strings.





void foo( char * f ) { f = "please please change"; }


void main() { char * t= "dont want to change"; foo(t); cout %26lt;%26lt; t; }


Now, :) i think by now you'd be saying "aaah, hmm... ". So, the solution. If you havent caught on, i'll tell you (this is Yahoo! Answers after all).. you've got two options


1. Pass parameter by reference ... void foo( char *%26amp; f )


2. Pass a pointer to the argument... void foo( char ** f )





I think you can figure out the rest. Due to the lack of availability of a compiler to check my analysis. I might be mistaken over char *%26amp; f... it might be, char %26amp;* f . But i dont think so. Sorry, but you'll have to check that.





Thanks.
Reply:I'm sorry if this is not what you want but I find it easier to just do this...





#include %26lt;iostream%26gt;


#include %26lt;fstream%26gt;


#include %26lt;string%26gt;


using namespace std;





char *rewriteString(char *str)


{


char * random = "theText";


return random;


}





int main() {


char * str = new char[100];


str = "Why am I outputting this, instead of what I want to output?";


str = rewriteString(str);


cout %26lt;%26lt; str;


system("PAUSE");


return 0;


}





===


I have no clue why you have the meaninglessInteger variable