fopen

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

    #16
    Re: fopen

    In article <%GE5k.40579$lE 3.1104@trnddc05 >,
    Bill Cunningham <nospam@nspam.c omwrote:
    fp = fopen ("data", "wa");
    I said to use "a", not "wa".
    --
    "MAMA: Oh--So now it's life. Money is life. Once upon a time freedom
    used to be life--now it's money. I guess the world really do change.
    WALTER: No--it was always money, Mama. We just didn't know about it."
    -- Lorraine Hansberry

    Comment

    • Bill Cunningham

      #17
      Re: fopen


      "Richard Heathfield" <rjh@see.sig.in validwrote in message
      news:g8KdnYe2zO ZlvMrVnZ2dneKdn ZydnZ2d@bt.com. ..
      Bill Cunningham said:
      >
      >>
      >"Bill Cunningham" <nospam@nspam.c omwrote in message
      >news:66D5k.209 48$3j2.17956@tr nddc03...
      >>>
      >>"Serve Lau" <nihao@qinqin.c omwrote in message
      >>news:e8de8$48 56df32$541fc2ec $30325@cache5.t ilbu1.nb.home.n l...
      >>
      > You know my book doesn't give return values for these functions for
      >error checking.
      >
      In message <3d38f60e_3@cor p.newsgroups.co m(posted on 20 July 2002) you
      wrote:
      >
      "This little K&R2 book is giving me the devil of a time."
      >
      It is not unreasonable to deduce from that statement that you have had a
      copy of K&R2 since at least 2002.
      >
      Despite your claim, K&R2 *does* document the return value semantics for
      fopen, freopen, fflush, fclose, fprintf, fscanf, fgetc, fgets, fputc,
      fputs, fread, fwrite, fseek, ftell, fgetpos, and fsetpos - on pp242-248.
      >
      >What about ftell and fseek do they return -1 or non zero
      >when successful ?
      >
      Read the book.
      >
      I may have to break it out. I have a little pocket reference I've leafed
      though. Couldn't find return values. Well I'll get them.

      Bill


      Comment

      • rahul

        #18
        Re: fopen

        On Jun 17, 8:35 am, "Bill Cunningham" <nos...@nspam.c omwrote:
        "Richard Heathfield" <r...@see.sig.i nvalidwrote in message
        >
        news:g8KdnYe2zO ZlvMrVnZ2dneKdn ZydnZ2d@bt.com. ..
        >
        Bill Cunningham said:
        >
        "Bill Cunningham" <nos...@nspam.c omwrote in message
        >news:66D5k.209 48$3j2.17956@tr nddc03...
        >
        >"Serve Lau" <ni...@qinqin.c omwrote in message
        >>news:e8de8$48 56df32$541fc2ec $30325@cache5.t ilbu1.nb.home.n l...
        >
        You know my book doesn't give return values for these functions for
        error checking.
        >
        In message <3d38f60...@cor p.newsgroups.co m(posted on 20 July 2002) you
        wrote:
        >
        "This little K&R2 book is giving me the devil of a time."
        >
        It is not unreasonable to deduce from that statement that you have had a
        copy of K&R2 since at least 2002.
        >
        Despite your claim, K&R2 *does* document the return value semantics for
        fopen, freopen, fflush, fclose, fprintf, fscanf, fgetc, fgets, fputc,
        fputs, fread, fwrite, fseek, ftell, fgetpos, and fsetpos - on pp242-248.
        >
        What about ftell and fseek do they return -1 or non zero
        when successful ?
        >
        Read the book.
        >
        I may have to break it out. I have a little pocket reference I've leafed
        though. Couldn't find return values. Well I'll get them.
        >
        Bill
        /* Code not compiled */
        #include <stdio.h>
        #include <stdlib.h>

        int
        main(int argc, char *argv[]) {
        double x;
        FILE *fp;
        x = strtod(argv[1], NULL);
        fp = fopen("foo", "a+");
        fprintf(fp, "%.2f", x);
        fclose(fp);
        return 0;
        }

        Probably this is what you want to do. The mode "a+" means open for
        appending and reading as well. Its not required if you just wish to
        append to the file.
        Return type for ftell is long. fseek returns int ( -1 on error, 0
        otherwise ). If you are on linux/unix box, use the man pages. If you
        are on a windows machine and using Visual Studio, you can use MSDN.
        Its better to have the documentation handy.

        Comment

        • Chris Thomasson

          #19
          Re: fopen

          "Bill Cunningham" <nospam@nspam.c omwrote in message
          news:5iG5k.6640 4$bs3.8292@trnd dc07...
          >
          "Richard Heathfield" <rjh@see.sig.in validwrote in message
          news:g8KdnYe2zO ZlvMrVnZ2dneKdn ZydnZ2d@bt.com. ..
          >Bill Cunningham said:
          >>
          >>>
          >>"Bill Cunningham" <nospam@nspam.c omwrote in message
          >>news:66D5k.20 948$3j2.17956@t rnddc03...
          >>>>
          >>>"Serve Lau" <nihao@qinqin.c omwrote in message
          >>>news:e8de8$4 856df32$541fc2e c$30325@cache5. tilbu1.nb.home. nl...
          >>>
          >> You know my book doesn't give return values for these functions for
          >>error checking.
          >>
          >In message <3d38f60e_3@cor p.newsgroups.co m(posted on 20 July 2002) you
          >wrote:
          >>
          > "This little K&R2 book is giving me the devil of a time."
          >>
          >It is not unreasonable to deduce from that statement that you have had a
          >copy of K&R2 since at least 2002.
          >>
          >Despite your claim, K&R2 *does* document the return value semantics for
          >fopen, freopen, fflush, fclose, fprintf, fscanf, fgetc, fgets, fputc,
          >fputs, fread, fwrite, fseek, ftell, fgetpos, and fsetpos - on pp242-248.
          >>
          >>What about ftell and fseek do they return -1 or non zero
          >>when successful ?
          >>
          >Read the book.
          >>
          I may have to break it out. I have a little pocket reference I've
          leafed though. Couldn't find return values. Well I'll get them.








































          ect...







          is you friend!

          Comment

          • CBFalconer

            #20
            Re: fopen

            Bill Cunningham wrote:
            "Richard Heathfield" <rjh@see.sig.in validwrote:
            >
            ><3d38f60e_3@co rp.newsgroups.c om(posted on 20 July 2002) you
            >wrote:
            >>
            > "This little K&R2 book is giving me the devil of a time."
            >>
            >It is not unreasonable to deduce from that statement that you
            >have had a copy of K&R2 since at least 2002.
            >>
            >Despite your claim, K&R2 *does* document the return value
            >semantics for fopen, freopen, fflush, fclose, fprintf, fscanf,
            >fgetc, fgets, fputc, fputs, fread, fwrite, fseek, ftell,
            >fgetpos, and fsetpos - on pp242-248.
            >>
            >>What about ftell and fseek do they return -1 or non zero
            >>when successful ?
            >>
            >Read the book.
            >
            I may have to break it out. I have a little pocket reference
            I've leafed though. Couldn't find return values.
            You should never have hidden it. It answers virtually every
            question you have asked here.

            --
            [mail]: Chuck F (cbfalconer at maineline dot net)
            [page]: <http://cbfalconer.home .att.net>
            Try the download section.

            ** Posted from http://www.teranews.com **

            Comment

            • CBFalconer

              #21
              Re: fopen

              Serve Lau wrote:
              "Bill Cunningham" <nospam@nspam.c omschreef in bericht
              >
              >I have a question about fopen. I want to append text to a text
              >file already written. I think this is what I need to do. If I am
              >correct fopen's second parameter takes only 2 letters. I am using
              >wt. To append text would I need another call to fopen if my text
              >file isn't already existing consisting of wa or a+ ?
              >
              read your favorite C book and try it out, its in there no matter
              if its a good or bad book
              You appear to devote your time to telling people not to ask
              questions, using incorrect punctuation.

              --
              [mail]: Chuck F (cbfalconer at maineline dot net)
              [page]: <http://cbfalconer.home .att.net>
              Try the download section.


              ** Posted from http://www.teranews.com **

              Comment

              • Serve Lau

                #22
                Re: fopen


                "CBFalconer " <cbfalconer@yah oo.comschreef in bericht
                news:4856EAF9.A 326DC80@yahoo.c om...
                Serve Lau wrote:
                >"Bill Cunningham" <nospam@nspam.c omschreef in bericht
                >>
                >>I have a question about fopen. I want to append text to a text
                >>file already written. I think this is what I need to do. If I am
                >>correct fopen's second parameter takes only 2 letters. I am using
                >>wt. To append text would I need another call to fopen if my text
                >>file isn't already existing consisting of wa or a+ ?
                >>
                >read your favorite C book and try it out, its in there no matter
                >if its a good or bad book
                >
                You appear to devote your time to telling people not to ask
                questions, using incorrect punctuation.
                Please show me my posts that justifies this general statement. Also please
                dont criticize my puntuation, it makes me feel VERY bad.

                Comment

                • CBFalconer

                  #23
                  Re: fopen

                  Serve Lau wrote:
                  "CBFalconer " <cbfalconer@yah oo.comschreef:
                  >Serve Lau wrote:
                  >>"Bill Cunningham" <nospam@nspam.c omschreef in bericht
                  >>>
                  >>>I have a question about fopen. I want to append text to a text
                  >>>file already written. I think this is what I need to do. If I am
                  >>>correct fopen's second parameter takes only 2 letters. I am using
                  >>>wt. To append text would I need another call to fopen if my text
                  >>>file isn't already existing consisting of wa or a+ ?
                  >>>
                  >>read your favorite C book and try it out, its in there no matter
                  >>if its a good or bad book ^^
                  > ^^
                  >You appear to devote your time to telling people not to ask
                  >questions, using incorrect punctuation.
                  >
                  Please show me my posts that justifies this general statement. Also
                  please dont criticize my puntuation, it makes me feel VERY bad.
                  ^^
                  Alright, I'll ignore punctuation. :-) As for general statements,
                  the quotation above will do.

                  --
                  [mail]: Chuck F (cbfalconer at maineline dot net)
                  [page]: <http://cbfalconer.home .att.net>
                  Try the download section.


                  ** Posted from http://www.teranews.com **

                  Comment

                  • Serve Lau

                    #24
                    Re: fopen


                    "CBFalconer " <cbfalconer@yah oo.comschreef in bericht
                    news:485AD88B.C F3F7D84@yahoo.c om...
                    >Please show me my posts that justifies this general statement. Also
                    >please dont criticize my puntuation, it makes me feel VERY bad.
                    ^^
                    Alright, I'll ignore punctuation. :-) As for general statements,
                    the quotation above will do.
                    get out more

                    Comment

                    • Richard Bos

                      #25
                      Re: fopen

                      "Serve Lau" <nihao@qinqin.c omwrote:
                      "CBFalconer " <cbfalconer@yah oo.comschreef in bericht
                      news:485AD88B.C F3F7D84@yahoo.c om...
                      Please show me my posts that justifies this general statement. Also
                      please dont criticize my puntuation, it makes me feel VERY bad.
                      ^^
                      Alright, I'll ignore punctuation. :-) As for general statements,
                      the quotation above will do.
                      >
                      get out more
                      Leer je talen correct schrijven, dwaze Belg. Je bent een belediging voor
                      het Nederlandse taalgebied.

                      Richard

                      Comment

                      Working...