Thread: Binary File Errors

  1. #1
    Registered User
    Join Date
    Aug 2014
    Posts
    16

    Question Binary File Errors

    For a big project for school I have to make an airline reservation simulator but I have run into a problem. I want to save the the flight code and its location in a binary file so that I can obtain a code according to the location but this happens:
    current output
    Binary File Errors-wxpkxpo-png

    The Expected output(made with notepad)

    Binary File Errors-tjwtnde-png

    Here is the source class
    Code:
    class file
    {
        private:
    
        char code[8];
        char from[20];
        public:
            void input();
            void show();
            char *getn()
            {
                return code;
            }
    };file fileobj;
    
    void file::input()
    {
        clrscr();
        cout<<"Enter Code+ no: ";
        gets(code);
        int A=strlen(code);
        if(A==6)
            strcat(code,"  ");
        else
            strcat(code," ");
        cout<<"Enter Location: ";
        gets(from);
        int a=20-strlen(from);
        for(int i=0;i<a;i++)
              strcat(from," ");
    }
    void file::show()
    {
        cout<<"Code: ";puts(code);
        cout<<"\t\tLocation: ";puts(from); }
    


    i have to make the program run on borland 5.02

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-07-2013, 04:33 PM
  2. Replies: 6
    Last Post: 12-06-2013, 11:39 PM
  3. Replies: 3
    Last Post: 11-28-2012, 09:16 AM
  4. Replies: 12
    Last Post: 06-18-2012, 08:23 AM
  5. oprantds errors of type int and const char [31] to binary???
    By Gaidin0147 in forum C++ Programming
    Replies: 1
    Last Post: 04-09-2003, 07:53 PM

Tags for this Thread