Skip to content

Instantly share code, notes, and snippets.

@sheki
Created October 9, 2011 06:20
Show Gist options
  • Select an option

  • Save sheki/1273374 to your computer and use it in GitHub Desktop.

Select an option

Save sheki/1273374 to your computer and use it in GitHub Desktop.
Meghana Project.
#include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
struct details
{
char *category;
char *name;
char *phone;
char *address;
//char area[100];
char *food_type;
char *timings;
int rating;
int code;
char *food_code;
};
int main()
{
ofstream fs("Restaurants1.txt", ios::app);
details arr;
int i=0;
char ch;
do
{
cout<<"Enter name of restaurant"<<i+1<<": ";
fflush(stdin);
gets(arr.name);
cout<<"Enter Category: ";
fflush(stdin);
gets(arr.category);
cout<<"Enter Phone number: ";
fflush(stdin);
gets(arr.phone);
cout<<"Enter address: ";
fflush(stdin);
gets(arr.address);
cout<<"Enter food type: ";
fflush(stdin);
gets(arr.food_type);
cout<<"Enter timings: ";
fflush(stdin);
gets(arr.timings);
cout<<"Enter rating: ";
cin>>arr.rating;
cout<<endl;
cout<<"Enter code: ";
cin>>arr.code;
cout<<endl;
fs.write((char*)&arr, sizeof(details));
i++;
cout<<"Want to add more??"<<endl;
cin>>ch;
}while(ch=='y' || ch=='Y');
fs.close();
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment