Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Opening a Binary File in Command

  1. May 28, 2012 #1
    How do you open a binary file in command in Pelles C so that it is readable?
     
  2. jcsd
  3. May 28, 2012 #2

    Borek

    User Avatar

    Staff: Mentor

    I would check if fopen("filename","rb") is not working.
     
  4. May 28, 2012 #3
    fopen is working
    Code (Text):

    void readFleet(Car_t toRead[])
    {
        FILE *fFleet;
        fFleet = fopen("Fleet_File.bin", "rb");
        fread(toRead, 10*sizeof(Car_t), 1, fFleet);
        fclose(fFleet);
    }
     
     
  5. May 28, 2012 #4
    My program on Pelles C is creating a binary file when I want the results to save to a file but I'm not sure on how to open the binary file in cmd in Pelles C so that it is readable and I can read it.
     
  6. May 28, 2012 #5

    phinds

    User Avatar
    Gold Member
    2016 Award

    "binary file" generally denotes a file that is NOT readable directly by humans, if that's what you mean. A file that is directly readable by humans is called a "flat file".
     
  7. May 28, 2012 #6
    I have 6 options in my code and it does create a binary file in my project folder when I press 4 but when I press 5 it doesn't work.

    Code (Text):
     
    printf("1. Add a car to the fleet.\n");
    printf("2. Delete last car from the fleet.\n");
    printf("3. Display full fleet on the screen.\n");
    printf("4. Save the fleet to a file.\n");
    printf("5. Read the fleet from a file.\n");
    printf("0. Exit the program\n");
    printf("\nPlease enter your choice:\n\n");
     
     
  8. May 29, 2012 #7

    Borek

    User Avatar

    Staff: Mentor

    What you just did is you have showed a mechanic the ignition key, and asked why your car is not starting. Zillions of things that can be wrong, the way your menu looks has probably nothing to do with any of them.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Opening a Binary File in Command
  1. C++ - File opening (Replies: 3)

Loading...