Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to close or recycle "FILE f_ptr" after using it

how to close or recycle "FILE f_ptr" after using it

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresperformancetutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrby123
    wrote on last edited by
    #1

    how to close or recycle FILE f_ptr after using it. e.g. FILE *f_ptr1 if((f_ptr1 = fopen(textFileName,"w")) == NULL) { ...} .... And how to recycle a array after use it within a program. double data[10000]; ....using it and finish use it how to close or destroy it so reserve the memory

    D 1 Reply Last reply
    0
    • M mrby123

      how to close or recycle FILE f_ptr after using it. e.g. FILE *f_ptr1 if((f_ptr1 = fopen(textFileName,"w")) == NULL) { ...} .... And how to recycle a array after use it within a program. double data[10000]; ....using it and finish use it how to close or destroy it so reserve the memory

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      mrby123 wrote:

      how to close...

      How about fclose()?

      mrby123 wrote:

      double data[10000]; ....using it and finish use it how to...destroy it

      It's on the stack. What's to destroy?


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      M 1 Reply Last reply
      0
      • D David Crow

        mrby123 wrote:

        how to close...

        How about fclose()?

        mrby123 wrote:

        double data[10000]; ....using it and finish use it how to...destroy it

        It's on the stack. What's to destroy?


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        M Offline
        M Offline
        mrby123
        wrote on last edited by
        #3

        fclose90 works, thanks! I mean in the heap? -- modified at 13:32 Thursday 13th April, 2006

        D 1 Reply Last reply
        0
        • M mrby123

          fclose90 works, thanks! I mean in the heap? -- modified at 13:32 Thursday 13th April, 2006

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          mrby123 wrote:

          I mean in the heap?

          mrby123 wrote:

          double data[10000];

          Memory for data has not been allocated on the heap. The only way to free it up is to close the application.


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          M 1 Reply Last reply
          0
          • D David Crow

            mrby123 wrote:

            I mean in the heap?

            mrby123 wrote:

            double data[10000];

            Memory for data has not been allocated on the heap. The only way to free it up is to close the application.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            M Offline
            M Offline
            mkuhac
            wrote on last edited by
            #5

            DavidCrow wrote:

            The only way to free it up is to close the application.

            Depends. If array data is global then yes.

            D 1 Reply Last reply
            0
            • M mkuhac

              DavidCrow wrote:

              The only way to free it up is to close the application.

              Depends. If array data is global then yes.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              mkuhac wrote:

              If array data is global...

              As opposed to what?


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups