how to split and join files in c or rust? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
how to split and join files in c or rust?.
I found the split, but saw nothing about joining the files.
I want to split files of various types, from text files to images
want in c or rust because i am using rust, so i can create rust module in c.
[Edit]
I'm making a program that divides files to send by tpc, so I need to divide and merge the files again

In C++, you split files by reading the master and writing to one or more new files.
This technique works with the C language also.
Joining files depends if you want to merge or append. In the append case, the destination file is opened with the "append" and write attribute. The file pointer is set to the end of the file, then stuff is written (appended) to the file.
IMHO, most file operations should be left to the OS as much as possible.

Related

C++ (file handling) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
When we are creating a file using code, it is important to define the extention of file like .txt, .dat , .jpg etc. But in c++ if we ommit the
extention of the file it still work fine. Why is it so? Also explain how the system will decide the correct extention of file as every thing
is in form of 0 and 1 in the memory?
The file extension is more like a suggestion. A ".jpg" file can have text in it and a ".txt" file can be sound. A file can have no extension. Even though it is relatively rare on windows, it is more common on systems like Linux.
We add extensions to tell the operating system and any software that will use the file what it contains. For example, when there is a ".mp3" file, the OS and other programs will know that it is a MPEG sound file.
You don't need extensions if you know what the file contains. However, since other people/programs might not know what the file contains, it is a good idea to use extensions.

How to load and parse the content of a text file into diferent variables [c++] [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i'm learning the basics of c++.
also at the same time i try to aplly what i've learned into a project.
i'm trying to make a GUI program for a command-line program.
the purpose of that program is to interact with PS2 Hard Drives, and i want to automate almost every feature it has.
the first thing i'm trying to do is parse a text file dumped by the program:
the text file contains a list of elements.
every element will contain this :
"media" "size" "Region Code" "name of the game"
Also, at the end of the file the total,used and free space of the HDD is written:
total 305152MB, used 199296MB, available 105856MB
I need to store into arrays (or vectors) the data of every game and the HDD space
Here's an example of what the text file looks like
https://mega.nz/file/o85SmLBZ#qf8FCXByI5-icz9LlSNFGiL7JXFArpwxODDLNrQ1LPc
Whatever I write to handle this will be executed several times (after erasing or installing games)
If you want to read and write to and from files, I suppose your best bet is the fstream library, which well... is used specifically to do that.
Here is a simple tutorial for the most fundamental ways to use the library.
Using this, you will read the file. There are examples for reading values one-by-one, but since the last line is specific, you might want to look into getline which shows up in that tutorial too.
Parsing it is the logic of your program, so I guess the first thing you want to do is put the values you read into arrays of some sort.

How to read in multiple text files into a program? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am writing a function that will take in a text file and do some manipulation on it. The files are stored in somewhat different places, such as:
/Documents/news/sports/something.txt where sports will be a folder with 20+ txt files
There are 20 more categories, stored such as: /Documents/news/next_category/something_else.txt
So the problem is that I want to pass in every txt file inside each folder inside the news folder, into my program, one by one. Is there a way to do this?
Thanks
i think you want to recursively enumerate the contents of a directory. I would use boost filesystem. It even has a recursive dir walk sample http://www.boost.org/doc/libs/1_61_0/libs/filesystem/doc/index.htm
also look here for other solutions How do you iterate through every file/directory recursively in standard C++?
Not with pure C++. C++ has no concept of directories, so you'll either have to interface with your OS's directory functions (like the C POSIX opendir and family) or use some library (like boost::filesystem)

C++ multiple big files in one binary file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
What is an efficient way to store multiple big files (100Mo to 5Go) in one binary file in c++ ?
For example, if I have an audio file, a very large image file, and a text file, I want to create a binary file that contains these three files and be able to retrieve them latter (to recreate the three original files).
Thanks for your help.
Short answer: Yes.
The long answer is it depends on how you want to package these things, what framing you want to use.
Do you need compression? Do you need random access? One way that's easy to implement is just using the zip container, it's well defined and there's a lot of libraries for creating and manipulating them. The same goes for the tar or cpio format.
The alternative is to write your own container format. This is a lot more difficult, you'll have to write an archiver and extractor.

structure reading C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have the following problem:
I have a configuration file that consists a description of fields , which I read it and then parse it. I want to move it into the code to compile it inside.
How would you do that as bug structure ??? or else ?
Thanks
I wouldn't move it into the code, I'd leave the configuration file as a configuration file.
If you really must do this, you can just embed the file as a string resource into the application and use that - that way you'd change only a minimal amount of existing code. The way you do this depends upon your platform.
If thats not feasible (for whatever reason) I'd set up a single configuration class / namespace to contain all the values.
It's not very clear what are you exactly asking.
If you are looking for on-the-fly code execution (like eval() function in some languages), then there is no such thing in C++. It's not an interpreted language which can be read and executed line-by-line, it needs to be compiled every time code changes. While it technically is possible to write self-changing code, it's probably not worth the effort.