truncate/decrease file

Discussion in 'C Programming' started by Neo, Jul 26, 2006.

  1. Neo

    Neo Guest

    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
    Neo, Jul 26, 2006
    #1
    1. Advertising

  2. Neo wrote:
    > 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?

    > Regard,
    > -aims
    Julienne Walker, Jul 26, 2006
    #2
    1. Advertising

  3. Neo <> wrote:
    > 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.



    --
    <Insert your favourite quote here.>
    Erik Trulsson
    Erik Trulsson, Jul 26, 2006
    #3
  4. Neo

    Richard Bos Guest

    "Neo" <> wrote:

    > 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.


    *Sigh* Mr. Summit, thine efforts are in vain.

    <http://c-faq.com/osdep/ftruncate.html>.

    HTH; HAND.

    Richard
    Richard Bos, Jul 26, 2006
    #4
  5. Neo

    Neo Guest

    Erik Trulsson wrote:
    > Neo <> wrote:
    > > 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.
    >
    >
    >
    > --
    > <Insert your favourite quote here.>
    > Erik Trulsson
    >


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

    regards,
    -aims
    Neo, Jul 26, 2006
    #5
  6. Neo

    Chris Dollin Guest

    Neo wrote:

    > 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.

    --
    Chris "seeker" Dollin
    "Who are you? What do you want?" /Babylon 5/
    Chris Dollin, Jul 26, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Correa

    Performance decrease after migration to .NET

    Christian Correa, Dec 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    350
    Christian Correa
    Dec 1, 2004
  2. Ravi Ambros Wallau
    Replies:
    1
    Views:
    508
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 14, 2006
  3. Neo

    truncate/decrease file

    Neo, Jul 26, 2006, in forum: C++
    Replies:
    2
    Views:
    385
    Kristo
    Jul 26, 2006
  4. Leslie Viljoen

    File#truncate fills file with zeros

    Leslie Viljoen, Nov 16, 2010, in forum: Ruby
    Replies:
    1
    Views:
    137
    Leslie Viljoen
    Nov 16, 2010
  5. botfood
    Replies:
    3
    Views:
    142
    J. Gleixner
    Sep 18, 2006
Loading...

Share This Page