Opening a Binary File in Command

In summary, The conversation discusses the topic of opening a binary file in command in Pelles C to make it readable. The suggested method of using "fopen" is mentioned and it is noted that the program is creating a binary file instead of a flat file. The speaker also mentions having 6 options in their code and encountering an issue with option 5. The conversation ends with a comment about showing a mechanic an ignition key and asking why a car won't start.
  • #1
dudforreal
116
0
How do you open a binary file in command in Pelles C so that it is readable?
 
Technology news on Phys.org
  • #2
I would check if fopen("filename","rb") is not working.
 
  • #3
Borek said:
I would check if fopen("filename","rb") is not working.

fopen is working
Code:
void readFleet(Car_t toRead[])
{
    FILE *fFleet;
    fFleet = fopen("Fleet_File.bin", "rb");
    fread(toRead, 10*sizeof(Car_t), 1, fFleet);
    fclose(fFleet);
}
 
  • #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.
 
  • #5
dudforreal said:
How do you open a binary file in command in Pelles C so that it is readable?

"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".
 
  • #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:
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");
 
  • #7
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.
 

FAQ: Opening a Binary File in Command

1. How do I open a binary file in command?

To open a binary file in command, you can use the command "open [filename]" followed by the appropriate file extension. For example, if your binary file is named "data.bin", you would use the command "open data.bin" to open it in command.

2. What is a binary file?

A binary file is a type of computer file that stores data in binary format, meaning the data is represented in a series of 1s and 0s. This format is commonly used for storing data that is not intended to be read or edited by humans, such as images, videos, and executables.

3. Can I edit a binary file in command?

Yes, you can edit a binary file in command by using a text editor or a specialized binary editor. However, it is important to note that any changes made to a binary file may cause it to become corrupted and unusable, so it is recommended to make a backup copy before editing.

4. How do I know if a file is binary or text?

You can determine if a file is binary or text by opening it in a text editor. If the file contains only readable characters and does not appear to be garbled or contain random characters, it is most likely a text file. If the file contains a combination of readable and unreadable characters, it is likely a binary file.

5. Are there any special commands for working with binary files in command?

Yes, there are special commands that can be used for working with binary files in command, such as "read [filename]" to read the contents of a binary file, "write [filename]" to write new data to a binary file, and "copy [source file] [destination file]" to copy a binary file to a new location.

Similar threads

Replies
57
Views
4K
Replies
33
Views
2K
Replies
10
Views
4K
Replies
20
Views
1K
Replies
9
Views
2K
Replies
12
Views
9K
Replies
4
Views
931
Replies
7
Views
2K
Back
Top