So, I have a C program where I am trying to save the binary code from a file that the user specifies. For example, if a user inputs a .txt or a .jpeg, or a .pdf, or whatever file extension they have, then I will be able to gather the binary code of the file. The catch is that the file will not be exclusively a .bin.
This is very specific to a project I am trying to make, so I don't see any documentation on how to achieve this. I believe this is achievable because technically every file is in binary, so, especially in C, this should be possible.
So far I have experimented by using fopen with an rb argument: file = fopen(filename, "rb"); because I am trying to modify the binary specifically. And i'm trying to gather the binary by using fseek(file, 0, SEEK_END); which should traverse the file.
I am coming from a Python/Java background, so any guidance or help is appreciated.
My question is what is the best way to achieve this?