Im creating an archive program.. I've created the archive and it can read in files, however in order to extract the files i need to be able to read in the file name and size.. any suggestions on how to do this..
Five answers:
?
2013-01-22 08:04:15 UTC
What I currently read is this:
a) you read a list of files from a given path and you are able to archive the files into an archive file
b) you need the file name and size in order to extract the files.
c) you do NOT want to use the file sizes and file names from the directory you archived the files from.
If this is the correct understanding then I propose the following solution:
You have to make file name and file size part of the archive:
you can determine the file size like this:
#include
#include
int main () {
FILE * pFile;
long lSize;
size_t result;
pFile = fopen ( "myfile.bin" , "rb" );
if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
else {
// obtain file size:
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
fclose(pFile);
}
return 0;
}
?
2016-04-27 21:20:12 UTC
Mastering the foundational reading skills allows your youngster to focus on knowledge the subject they are examining as opposed to struggle with understanding the words ultimately leading to a more gratifying and satisfying reading knowledge and that is in what this program Children Learning Reading from here https://tr.im/110pC is based.
Children Learning Reading use methods to help your son or daughter read and increase his reading, awareness, and punctuation ability in the first college years.
Even though the Kiddies Understanding Reading program relies about your youngster understanding the little looks which make up each term there are a few phrases in the English language that only can't be learned in this way (rhythm for example). In order to help one to show your youngster these outstanding phrases an guide is presented to the most typical words that have to be learned by sight.
This benefit could be especially useful in the event that you and your child are fighting a particular word. You understand that if the term is included in the guide then it's a thing that can not be trained using the Children Learning Reading method.
husoski
2013-01-22 06:29:22 UTC
There's no portable way to read a directory in C (or C++ for that matter). In Unix-like operating systems, you can use opendir() and readdir(). There's an example here:
Windows is messier. From C, you must use the Win32 APIs. The runtime library has some of the Unix-style I/O functions, but not opendir/readdir. The Win32 functions to use are FindFirstFile, FindNextFile(), and FindClose(). The following page gives a sample.
That works as-is compiled as a C program in Visual Studio, but not in GNU GCC for windows (MinGW). You'll have to remove the header and recode the string handling to work on a non-MS compiler. As you can see from the source code, MS doesn't want you to use standard C.
amania_r
2013-01-22 05:20:28 UTC
The stat() system call will return data including the file size.
You need to use directory operations to find file names in the directory.
Use opendir(), readdir(), closedir()
2017-01-11 18:52:01 UTC
Why do not you purely study the completed document into an array of personality strings? Then only print the call at a given random index. provided that the traditional call is way less then 20 characters, it really is purely about (1000x20) 20K of memory required, and a lot swifter get admission to.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.