truncate/decrease file

N

Neo

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 file.
In C _chsize function provides to change the file size/truncation of
file but i am not like to use io.h function therefore any one help to
solve my problem?

Regard,
-aims
 
J

Julienne Walker

Neo said:
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 file.
In C _chsize function provides to change the file size/truncation of
file but i am not like to use io.h function therefore any one help to
solve my problem?

Implementation-specific library functions are off-topic for this
newsgroup, as are platform-dependent APIs. Perhaps
microsoft.public.vc.language or comp.os.ms-windows.programmer.win32?
 
E

Erik Trulsson

Neo said:
I want to remove 10 bytes from end of the file, how I can perform this
task using C filing functions? (Using vs2k5)

There is no function in standard C that can do this.

Most Unix-like systems have a truncate() function that do what you want,
but truncate() is not part of standard C, and thus not available everywhere.
I am not want to make new, write contents, remove input file and rename
output file.

If you want to stick to standard, portable C, I am afraid that is your only choice.
In C _chsize function provides to change the file size/truncation of
file but i am not like to use io.h function therefore any one help to
solve my problem?

_chsize and io.h are not part of C.
 
N

Neo

Erik said:
There is no function in standard C that can do this.

Most Unix-like systems have a truncate() function that do what you want,
but truncate() is not part of standard C, and thus not available everywhere.


If you want to stick to standard, portable C, I am afraid that is your only choice.


_chsize and io.h are not part of C.

how i make portable code in C? either define macros or some thing else?
if macros then how?

regards,
-aims
 
C

Chris Dollin

Neo said:
how i make portable code in C?

Don't use things that aren't defined by the standard, and
use them within their defined limits.

If you must use things that aren't standard, isolate them so
that you know where and what you have to change when you
port.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top