in Education by
Is there a function in the C Library under Linux which can set the length of a file? Under Windows I know there is a SetFileLength() function. If there is not, what is the best way of shortening a file without deleting and rewriting it? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use the truncate function. int truncate(const char *path, off_t length); From the man page: "The truncate() and ftruncate() functions cause the regular file named by path or referenced by fd to be truncated to a size of precisely length bytes. If the file previously was larger than this size, the extra data is lost. If the file previously was shorter, it is extended, and the extended part reads as null bytes"

Related questions

0 votes
    A Flow Library contains a set of ______ used for common tasks like notarizing a transaction, gathering required signatures, etc. A. Flows B. Contracts C. Transactions D. Cordapps...
asked Feb 23, 2023 in Technology by JackTerrance
0 votes
    // merge.cpp // merges two containers into a third #include #include //for merge() using namespace std; int src1[] = { 2, 3, 4, ... , src1+5, src2, src2+3, dest); for(int j=0; j...
asked Jun 2, 2022 in Education by JackTerrance
+1 vote
    Which built-in library function can be used to re-size the allocated dynamic memory in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    Can a static library (.a) contain resources like images, sound files etc?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    which company has created Ubuntu linux. a.canonicial ltd. b.reliance. c.IBM Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    1.Which of the following software is not system software? a) Windows b)MS Word c)Linux d)DOS 2.Which of the ... Vista d) Windows NT Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    __________ function is used to watch for all available packages in library. (a) lib() (b) fun.lib() (c ... Started of R Programming Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    This question's answers are a community effort. Edit existing answers to improve this post. It is not ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    The following are operating system processing program except? A. Control programs B. Utility programs C. Library ... Linkage editor Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    a. State the number of bytes occupied by char and int data types. b. Differentiate between = and == ... implicit type conversion. Select the correct answer from above options...
asked Dec 6, 2021 in Education by JackTerrance
0 votes
    a. State the number of bytes occupied by char and int data types. b. Differentiate between = and == ... implicit type conversion. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    a. State the number of bytes occupied by char and int data types. b. Differentiate between = and == ... implicit type conversion. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
...