how to use the open() call

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pal

    #1

    how to use the open() call

    Hi,

    How to use the open() ( mean syntax ) to open a file and to append the
    data every time at the end of the file.


    My Problem is,

    I created a file and written some data into it, and second time i
    opened the file with the open() like
    fd = open ("\dir\file.dat ",O_WRONLY, 0); and written some data into
    this file.

    But always I am not able to append the data to the file.instead it is
    overwriting the file.
    Is there any way to solve this problem .


    Thanks.


  • Martin Ambuhl

    #2
    Re: how to use the open() call

    pal wrote:
    Hi,
    >
    How to use the open() ( mean syntax ) to open a file and to append the
    data every time at the end of the file.
    Unfortunately, open() is not a standard C call, and its meaning, syntax,
    and attendant issues are determined by the implementation that you are
    using. It is likely that that is a Unix-like one, in which case a Unix
    (or Posix or Linux) newsgroup is the right one. The usual Posix/Unix
    open() yields an int called a file-descriptor, which is not the way
    streams are referenced in the standard C library. There the similar
    call is fopen() which yields pointer-to-FILE. If you have trouble using
    the standard C functions, this is the place. If your problem is with an
    implementation-specific function like open(), this is not the place for it.

    Comment

    • viza

      #3
      Re: how to use the open() call

      On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
      How to use the open() ( mean syntax ) to open a file and to append the
      data every time at the end of the file.
      RTFM: man 2 open

      Look for the bit about O_APPEND.

      Comment

      • vippstar@gmail.com

        #4
        Re: how to use the open() call

        On Aug 19, 3:01 pm, viza <tom.v...@gm-il.com.obviousc hange.invalid>
        wrote:
        On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
        How to use the open() ( mean syntax ) to open a file and to append the
        data every time at the end of the file.
        >
        RTFM: man 2 open
        >
        Look for the bit about O_APPEND.
        Off-topic in comp.lang.c
        It would be more appropriate in comp.unix.progr ammer where the POSIX
        standard is topical.

        Comment

        • viza

          #5
          Re: [OT] how to use the open() call

          On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
          On Aug 19, 3:01 pm, viza wrote:
          >On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
          >>How to use the open() ( mean syntax ) to open a file and to append
          >Look for the bit about O_APPEND.
          Off-topic in comp.lang.c

          Comment

          • Richard Heathfield

            #6
            Re: [OT] how to use the open() call

            viza said:
            On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
            >On Aug 19, 3:01 pm, viza wrote:
            >>On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
            >
            >>>How to use the open() ( mean syntax ) to open a file and to append
            >
            >>Look for the bit about O_APPEND.
            >
            >Off-topic in comp.lang.c
            >
            http://biblecc.com/luke/6-9.htm
            Not really applicable - vippstar gave an appropriate redirection with the
            intent of getting *better* help for the OP.

            If someone asks for a newspaper in the butcher's shop, the shopkeeper who
            reaches under the counter and pulls out a grease-spotted newspaper dating
            back two weeks and with the Sudoku already half-filled in is not
            performing as great a service as the shopkeeper who redirects the enquirer
            next door to the newsagent.

            --
            Richard Heathfield <http://www.cpax.org.uk >
            Email: -http://www. +rjh@
            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
            "Usenet is a strange place" - dmr 29 July 1999

            Comment

            • Chad

              #7
              Re: how to use the open() call

              On Aug 20, 7:35 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
              viza said:
              >
              On Tue, 19 Aug 2008 16:54:06 -0700, vippstar wrote:
              On Aug 19, 3:01 pm, viza wrote:
              >On Tue, 19 Aug 2008 03:16:20 -0700, pal wrote:
              >
              >>How to use the open() ( mean syntax ) to open a file and to append
              >
              >Look for the bit about O_APPEND.
              >
              Off-topic in comp.lang.c
              >>
              Not really applicable - vippstar gave an appropriate redirection with the
              intent of getting *better* help for the OP.
              >
              If someone asks for a newspaper in the butcher's shop, the shopkeeper who
              reaches under the counter and pulls out a grease-spotted newspaper dating
              back two weeks and with the Sudoku already half-filled in is not
              performing as great a service as the shopkeeper who redirects the enquirer
              next door to the newsagent.
              >
              <OT>
              Geeze, a while back I made a similar comment to another person.
              Shortly after that, I got all these snide responses.
              </OT>

              Comment

              • Richard Heathfield

                #8
                Re: how to use the open() call

                Chad said:
                On Aug 20, 7:35 am, Richard Heathfield <r...@see.sig.i nvalidwrote:
                <snip>
                >vippstar gave an appropriate redirection with
                >the intent of getting *better* help for the OP.
                >>
                >If someone asks for a newspaper in the butcher's shop, the shopkeeper
                >who reaches under the counter and pulls out a grease-spotted newspaper
                >dating back two weeks and with the Sudoku already half-filled in is not
                >performing as great a service as the shopkeeper who redirects the
                >enquirer next door to the newsagent.
                >>
                >
                <OT>
                Geeze, a while back I made a similar comment to another person.
                Shortly after that, I got all these snide responses.
                </OT>
                Fear not. I'm sure some snide responses are winging their way to me even as
                I write this.

                --
                Richard Heathfield <http://www.cpax.org.uk >
                Email: -http://www. +rjh@
                Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                "Usenet is a strange place" - dmr 29 July 1999

                Comment

                Working...