hai,
i am developing a program which helps in reserving a ticket in railway. i am facing problem for the cancellation process. i had done all file operations (open,write..) in binary mode....
expecting a fast solution.......

A solution to what exactly? Give us something to work with...

Oh, and check here as well.

commented: Precisely +18

i'm trying to make a railway reservation program using file handling. some errors are occurred. i tried but i cant correct. some instructions and some errors are commented aside. pls help me....

#include<process.h>

#include<fstream.h>

#include<stdio.h>

#include<conio.h>

#include<string.h>



const int MAX = 50;



struct person

{

       char Name[MAX];

       int Age;

       char sex;

       char to,from;

}Passenger[MAX];



//insert all the data to Passenger[0];







class Train

{

   private :



       char  TrainNo[10];

	// Total seats available..

       int TotalSeats;

       // Simply, name of the train, used only for display

       char TrainName[MAX];

   public :

	void Alter();

	//int Trainreport(int/*tr no: */); //search the file and display

	void Trainadd();

	int Traindelete(); // system ("del <filname>");

};





class Reservation

{

   private:



		char PNR[15];

       person Passenger;//structure

       // class Date { }; // This is complex, do if you want



   public :



       int Reserve ()

	{



		generatePNR();

		fstream Database;

		Database.open (PNR, ios::out | ios::app | ios::binary );

		Database.write ( (char *) &Passenger[0], sizeof (person) );

		Database.close();

	       /*cannot convert person to int &

	       invalid indirection &

	       could not find for 'ostream :: write (undined,unsigned int)*/

		 return(0);

       }



	   void generatePNR()

	   {

		   fstream pnr;

		   pnr.open("pnr", ios::in | ios::binary );

		   pnr.read((char *) &PNR, sizeof(char));

		   pnr.close();

		   unsigned int x = atoi(PNR); // to convert sting to number

		   x++;

		   PNR= atoa(x); // L value, atoa & atoi prototype



		   pnr.open("pnr", ios::out | ios::binary );

		   pnr.write((char *) &PNR, sizeof(char));

		   pnr.close();









	  }



       int Cancel()

	 {

	  cout<<"\n Enter the  PNR no: -";

	  gets(PNR);

	  system ("del <PNR>");

	  cout<<"\n tickect canceled !!!";

	  return 0;

	 }// system ("del <filename>); // Filename as PNR

};

 class PNR

 {

	person Passenger;

	char cpnr;

   public:

	void get();

	void getpnrno();

	void print();

  };

 void main()

   {

	int Reserve ();//paramater names aee used only with a function body

	clrscr();

	cout << "\n\n\t\t\t  Welcome to\\n\n\n\n\n";

	gotoxy (8,8);

	int x = 8, y = 10,i;

	gotoxy (x,y++);



	 cout<<" ____           _  _                        \n";gotoxy(x,y++);

	 cout<<"|  _ \\     _ _ (_)| |__      __   _ _  _   _\n";gotoxy(x,y++);

	 cout<<"| |_) |  / _` || || |\\ \\ /\\ / / / _` || | | |\n";gotoxy(x,y++);

	 cout<<"|  _ <  | (_| || || | \\ V  V / | (_| || |_| |\n";gotoxy(x,y++);

	 cout<<"|_| \\_\\ \ \\__,_||_||_|  \\_/\\_/   \\__,_| \\__, |\n";gotoxy(x,y++);

	 cout<<"                                       |___/ \n\n\n\n";gotoxy(x,y++);



	 cout<<" ____                                             _    _  \n";gotoxy(x,y++);

	 cout<<"|  _ \\   ___  ___  _ __ __   __ ___ __   __ __ _ | |_ (_)  ___   _ _\n"; gotoxy(x,y++);

	 cout<<"| |_) | / _ \\/ __|| '__|\\ \\ / // _ \\\\ \\ / // _` || __|| | / _ \\ | '_ \\\n"; gotoxy(x,y++);

	 cout<<"| _  < |  __/\\__ \\| |    \\ V /|  __/ \\ V /| (_| || |_ | || (_) || | | |\n" ;gotoxy(x,y++);

	 cout<<"|_| \\_\\ \\___||___/|_|     \\_/  \\___|  \\_/  \\__,_| \\__||_| \\___/ |_| |_|\n\n\n\n";gotoxy(x,y++);





	 cout<<" ____                  _\n";gotoxy(x,y++);

	 cout<<"/ ___|   _   _   ___  | |_    ___   _ __ ___\n";gotoxy(x,y++);

	 cout<<"\\___ \\  | | | | / __| | __|  / _ \\ | '_ ` _ \\ \n";gotoxy(x,y++);

	 cout<<" ___) | | |_| | \\__ \\ | |_  |  __/ | | | | | |\n";gotoxy(x,y++);

	 cout<<"|____/   \\__, | |___/  \\__|  \\___| |_| |_| |_|\n";gotoxy(x,y++);

	 cout<<"         |___/\n";gotoxy(x,y++);

	 getch();

	 cout<<"\n\n\n\n        __________________________________________________________________\n\n\t\t  \t(press any key to continue)\n        __________________________________________________________________";

	 getch();

	 clrscr();

	 int menu;

	 char choice;

	 Reservation ob;

	 Train tr;

	 do

	  {

	    cout<<"\n\n\n\n\n\n\n\n\n\n\t\t     *************....M E N U....*************\n";

	    cout<<"\n\n\n\t\t\t    1 : Reservation\n\t\t\t    2 : Cancelation\n\t\t\t    3 : Print\n\t\t\t    4 : Altertrain\n\t\t\t    5 : Exit";

	    cout<<"\n\n\n\n\n\tEnter your choice  :  ";

	    cin>>menu;

	    switch (menu)

	     {

		case 1: Reserve(ob);break;//reseve should have prototype

		case 2: Cancel(ob);break;//  prototype

		case 3: ;break;

		case 4: tr.Alter();break;

		case 5: exit(0);

		default :  cout<<"invalid choice";

	     }

		 // if(menu==4) system("exit");

	    cout<<"\n\n\n\n \t\t\t     Do you want to continue (y/n)?";

	    cin>>choice;

	    clrscr();

	  } while(choice=='y');

	 getch();

   }

	     void Train :: Trainadd()

		      {

			 cout<<"\nEnter no: ";

			 cin>>TrainNo;

			 cout<<"\nEnter the train name :";

			 gets(TrainName);

			 cout<<"The total no: of seats";

			 cin>>TotalSeats;

		      }

	     int Train :: Traindelete()

		      {

			 cout<<"traindelete";//need to expand

			 return 0;

		      }

	     void Train :: Alter()

		      {

			 cout<<"\t\t\t\t\t*** ALTER MENU ***\n\t\t_________________________________________\n\n";

			 int alterchoz;

			 cout<<"\t\t\t 1 : Add Train\n\t\t\t 2 : Delete Train\n\n\n \t\t\t Enter the choice : ";

			 cin>>alterchoz;

			 switch (alterchoz)

			   {

				case 1: clrscr();

				void Trainadd();

				cout<<"\nTrain added sucessfully ! !" ;

					//write this to file new file should be created wit train no as filename

					break;

				case 2:clrscr();

				int Traindelete();

				/* should ask for the train number : ";

				     //search the file name and delete the file

					break;



				default : cout<<"invaild choice";*/

		      }

	     void PNR :: getpnrno()    // identifier 'getpnr' cannot have a type qualifier

	     {

		cout<<"\n Enter the PNR no: - ";

		gets(PNR);

	     }

	     void PNR :: get()

	     {

		fstream ob;

		ob.open(cpnr, ios::in | ios:: binary );

		ob.read((char*) this, sizeof(PNR));

	     }

	     void PNR :: print()

	     {

	       cout<<"\n\n\n\n\n\n\n\t\t Name  : "<< Name;

	       cout<<"\n\n\n\n\n\n\n\t\t Age   : "<< Age;

	       cout<<"\n\n\n\n\n\n\n\t\t Sex   : "<< Sex;

	       cout<<"\n\n\n\n\n\n\n\t\t From  : "<< from;

	       cout<<"\n\n\n\n\n\n\n\t\t To    : "<< to;

	       cout<<"\n\n\n\n\n\n\n\t\t PNRno : "<< cpnr;

	     }  //declaration missing



	     /* char s[10];

		    strcpy(s,"1000000");

			fstream pnr;

		   pnr.open("pnr", ios::out | ios::binary );

		   pnr.write((char *) &PNR, sizeof(char));

		   pnr.close();

		   what should i do with this??

	     */

I can't read this code. Remove the extra whitelines and repost it.

Are you a 12th class student making a C++ project for CBSE boards?

whats identifier and type qualifier ?

hai,
i am developing a program which helps in reserving a ticket in railway. i am facing problem for the cancellation process. i had done all file operations (open,write..) in binary mode....
expecting a fast solution.......

Are you a 12th class student making a C++ project for CBSE boards?

i'm in 12th board of kerala

Please help me to write a C++ program which reserves seats in train(railway reservation system ). I'm a beginner in C++ and have read all the posts related to this topic ,but it didn't help me at all. i have tried a lot.... but at last finished it with one error left... the error is "identifier getpnrno should not have a type qualifier" i cant correct as i dont know whats its meaning. pls help me.... i am keeping the code below.... pls help me

#include<process.h>

#include <stdlib.h>

#include<fstream.h>

#include<stdio.h>

#include<conio.h>

#include<string.h>



const int MAX = 50;



struct person
{

  char Name[MAX];

  int Age;

  char sex;

  char to, from;

} Passenger;



//insert all the data to Passenger[0];







class Train
{

  private:char TrainNo[10];

  int TotalSeats;

  char TrainName[MAX];

    public:void Alter ();

  void Trainadd ();

  int Traindelete ();

};



class Reservation
{

private:

  char PNR[15];

  person Passenger;		//structure

    public:int Reserve ()
  {



    generatePNR ();

    fstream Database;

      Database.open (PNR, ios::out | ios::app | ios::binary);

      Database.write ((char *) &Passenger, sizeof (person));

      Database.close ();

      return (0);

  }



  void generatePNR ()
  {

    fstream pnr;

    pnr.open ("pnr", ios::in | ios::binary);

    pnr.read ((char *) &PNR, sizeof (char));

    pnr.close ();

    int x = atoi (PNR);		// to convert sting to number

    x++;

    itoa (x, PNR, 10);

    pnr.open ("pnr", ios::out | ios::binary);

    pnr.write ((char *) &PNR, sizeof (char));

    pnr.close ();

  }



  int Cancel ()
  {

    cout << "\n Enter the PNR no: -";

    gets (PNR);

    system ("del <PNR>");

    cout << "\n tickect canceled !!!";

    return 0;

  }

};

class PNR
{

  person Passenger;

  char cpnr;

public:

  void get ();

  void getpnrno ();

  void print ();

};

void
main ()
{

  int Reserve ();

  int Cancel ();

  clrscr ();

  cout << "\n\n\t\t\t Welcome to\\n\n\n\n\n";

  gotoxy (8, 8);

  int x = 8, y = 10, i;

  gotoxy (x, y++);



  cout << " ____ _ _ \n";
  gotoxy (x, y++);

  cout << "| _ \\ _ _ (_)| |__ __ _ _ _ _\n";
  gotoxy (x, y++);

  cout << "| |_) | / _` || || |\\ \\ /\\ / / / _` || | ||\n";
  gotoxy (x, y++);

  cout << "| _ < | (_| || || | \\ V V / | (_| || |_| |\n";
  gotoxy (x, y++);

  cout << "|_| \\_\\ \ \\__,_||_||_| \\_/\\_/ \\__,_| \\__,|\n";
  gotoxy (x, y++);

  cout << " |___/\n\n\n\n";
  gotoxy (x, y++);



  cout << " ____ _ _\n";
  gotoxy (x, y++);

  cout << "| _ \\ ___ ___ _ __ __ __ ___ __ __ __ _ | |_ (_)___ _ _\n";
  gotoxy (x, y++);

  cout <<
    "| |_) | / _ \\/ __|| '__|\\ \\ / // _ \\\\ \\ / // _` || __|| |/ _ \\
| '_ \\\n";
  gotoxy (x, y++);

  cout << "| _ < | __/\\__ \\| | \\ V /| __/ \\ V /| (_| || |_ | ||(_) || | |
|\n";
  gotoxy (x, y++);

  cout <<
    "|_| \\_\\ \\___||___/|_| \\_/ \\___| \\_/ \\__,_|\\__||_| \\___/ |_|
|_|\n\n\n\n";
  gotoxy (x, y++);





  cout << " ____ _\n";
  gotoxy (x, y++);

  cout << "/ ___| _ _ ___ | |_ ___ _ __ ___\n";
  gotoxy (x, y++);

  cout << "\\___ \\ | | | | / __| | __| / _ \\ | '_ ` _ \\\n";
  gotoxy (x, y++);

  cout << " ___) | | |_| | \\__ \\ | |_ | __/ | | | | ||\n";
  gotoxy (x, y++);

  cout << "|____/ \\__, | |___/ \\__| \\___| |_| |_||_|\n";
  gotoxy (x, y++);

  cout << " |___/\n";
  gotoxy (x, y++);

  getch ();

  cout <<
    "\n\n\n\n__________________________________________________________________\n\n\t\t\t(pressany
key
tocontinue)\n__________________________________________________________________";

  getch ();

  clrscr ();





  cout << " ____ _\n";
  gotoxy (x, y++);

  cout << "/ ___| _ _ ___ | |_ ___ _ __ ___\n";
  gotoxy (x, y++);

  cout << "\\___ \\ | | | | / __| | __| / _ \\ | '_ ` _\\\n";
  gotoxy (x, y++);

  cout << " ___) | | |_| | \\__ \\ | |_ | __/ | | | |||\n";
  gotoxy (x, y++);

  cout << "|____/ \\__, | |___/ \\__| \\___| |_||_||_|\n";
  gotoxy (x, y++);

  cout << " |___/\n";
  gotoxy (x, y++);

  getch ();



  cout <<
    "\n\n\n\n__________________________________________________________________\n\n\t\t\t(pressanykeytocontinue)\n__________________________________________________________________";

  getch ();

  clrscr ();

  int menu;

  char choice;

  Reservation ob;

  Train tr;

  do

    {

      cout <<
	"\n\n\n\n\n\n\n\n\n\n\t\t *************....MENU....*************\n";

      cout << "\n\n\n\t\t\t 1 : Reservation\n\t\t\t 2:Cancelation\n\t\t\t3 :
Print\n\t\t\t 4 : Altertrain\n\t\t\t 5:Exit";

      cout << "\n\n\n\n\n\tEnter your choice : ";

      cin >> menu;

      switch (menu)

	{

	case 1:
	  ob.Reserve ();
	  break;		//reseve should have prototype

	case 2:
	  ob.Cancel ();
	  break;		// prototype

	case 3:;
	  break;

	case 4:
	  tr.Alter ();
	  break;

	case 5:
	  exit (0);

	default:
	  cout << "invalid choice";

	}

      cout << "\n\n\n\n \t\t\t Do you want to continue (y/n)?";

      cin >> choice;

      clrscr ();

    }
  while (choice == 'y');

  getch ();

}

void
Train::Trainadd ()
{

  cout << "\nEnter no: ";

  cin >> TrainNo;

  cout << "\nEnter the train name :";

  gets (TrainName);

  cout << "The total no: of seats";

  cin >> TotalSeats;

}

int
Train::Traindelete ()
{

  cout << "traindelete";

  return 0;

}

void
Train::Alter ()
{

  cout <<
    "\t\t\t\t\t***ALTERMENU***\n\t\t_________________________________________\n\n";

  int alterchoz;

  cout << "\t\t\t 1 : Add Train\n\t\t\t 2 : Delete Train\n\n\n\t\t\tEnter the
choice : ";

  cin >> alterchoz;

  switch (alterchoz)

    {

    case 1:
      clrscr ();

      void Trainadd ();

      cout << "\nTrain added sucessfully ! !";

      break;

    case 2:
      clrscr ();

      int Traindelete ();

    default:
      cout << "invaild choice";

    }

  void PNR::getpnrno ()
  {

    cout << "\n Enter the PNR no: - ";

    gets (PNR);

  }

  void PNR::get ()
  {

    fstream ob;

    ob.open (cpnr, ios::in | ios::binary);

    ob.read ((char *) this, sizeof (PNR));

  }

  void PNR::print ()
  {

    cout << "\n\n\n\n\n\n\n\t\t Name : " << Name;

    cout << "\n\n\n\n\n\n\n\t\t Age : " << Age;

    cout << "\n\n\n\n\n\n\n\t\t Sex : " << Sex;

    cout << "\n\n\n\n\n\n\n\t\t From : " << from;

    cout << "\n\n\n\n\n\n\n\t\t To : " << to;

    cout << "\n\n\n\n\n\n\n\t\t PNRno : " << cpnr;

  };

}

You don't appear to have closed the scope of Train::Alter() properly, you need another close brace ('}') in there somewhere. Because of this, you are trying to define PNR::getpnrno() inside the scope of Train::Alter() which is illegal (see lines 368-405). You may call other functions from within the scope of a particular function by stating the function's name and arguments, but you may not define an entirely new function.

can anyone help me in doing railway reservation system using visual basic

can anyone help me in doing railway reservation system using visual basic

Sure and the guy is here