473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

truncate/decrease file

Neo
I want to remove 10 bytes from end of the file, how I can perform this
task using C++ filing functions?
I am not want to make new, write contents, remove input file and rename
output file.
In C++ ios::trunc flag available use for truncation but how to use
trunk flag in my task?

Regard,
-aims

Jul 26 '06 #1
2 8882
Neo

in other words change the size of file using C++ functions...

Regard,
-aims

Jul 26 '06 #2
Neo wrote:
I want to remove 10 bytes from end of the file, how I can perform this
task using C++ filing functions?
I am not want to make new, write contents, remove input file and rename
output file.
In C++ ios::trunc flag available use for truncation but how to use
trunk flag in my task?
ios::trunc, along with ios::out, is the default open mode for a file
opened by an ofstream object. That means when you open a file for
writing, it is truncated to zero, i.e., cleared. So if you want to
truncate 10 bytes off a file...

1. open the file for reading
2. read the contents into a buffer
3. close the file
4. open it for writing
5. write out the buffer except the last 10 bytes.

Kristo

Jul 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yannick Turgeon | last post by:
Hello all, I just started to use perl and I'm having a Regexp question: Say we've got a file with this in it: ---- Beginning of file after this line -------- My list A: cat B: dog C: horse
1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
4
by: Amit Kulkarni | last post by:
Hi, I have small problem. I want to truncate a line in a text file using C file handling functions and write new line in place of it. How do I do it? e.g. "example.txt" Line 1: This is a...
1
by: venkat | last post by:
Hi, Can any one tell me the best way to truncate a file if it exceeds a specified file size? I need to truncate the start of the file by the appropriate amount (The data to insert). Is there any...
5
by: ronin 47th | last post by:
Hi group, In one of the books 'Gurus Guide to Transact SQL' i found this info: ------------------------------------------------------------ TRUNCATE TABLE empties a table without logging row...
2
by: Sharkie | last post by:
I'm relatively new to XSLT, having strong background in bunch of other programming languages (Perl, Java, etc.). I'm writing an XSLT stylesheet, converting XML into HTML. Everything works just...
5
by: Neo | last post by:
I want to remove 10 bytes from end of the file, how I can perform this task using C filing functions? (Using vs2k5) I am not want to make new, write contents, remove input file and rename output...
1
by: hedgracer | last post by:
I would like to allow a particular user to truncate a log file in a stored procedure that the user runs every day. At this moment the only personnel that can truncate the log file are personnel...
2
by: s0suk3 | last post by:
file.truncate(X) will truncate the file to at most X bytes (i.e. leave the first X bytes of the file and throw away the rest). Is there a way to throw away, say, the first X bytes of the file, and...
5
by: Timothy Madden | last post by:
Hello I see there is now why to truncate a file (in C or C++) and that I have to use platform-specific functions for truncating files. Anyone knows why ? I mean C/C++ evolved over many years...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.