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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. fstream

fstream

Scheduled Pinned Locked Moved C / C++ / MFC
ioshelp
6 Posts 4 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.
  • K Offline
    K Offline
    kk tvm
    wrote on last edited by
    #1

    Hi In my program, i use read/write mode for file operation. But it not working properly. Code as follows fstream f("temp.txt",ios::app | ios::in ) kindly help thanks

    KK

    C M 2 Replies Last reply
    0
    • K kk tvm

      Hi In my program, i use read/write mode for file operation. But it not working properly. Code as follows fstream f("temp.txt",ios::app | ios::in ) kindly help thanks

      KK

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      kk.in wrote:

      But it not working properly

      Fine, and we are supposed to guess what is going wrong ? And what you are expecting ?

      kk.in wrote:

      ios::app | ios::in

      You know that you will only be able to read the file (and I don't know why you used ios::app here, this is only usefull when writing to the file).


      Cédric Moonen Software developer
      Charting control [Updated - v1.1]

      K 1 Reply Last reply
      0
      • K kk tvm

        Hi In my program, i use read/write mode for file operation. But it not working properly. Code as follows fstream f("temp.txt",ios::app | ios::in ) kindly help thanks

        KK

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

        i think you need to use fstream f("temp.txt",ios::out | ios::in ), then it will work i think mpk1979

        1 Reply Last reply
        0
        • C Cedric Moonen

          kk.in wrote:

          But it not working properly

          Fine, and we are supposed to guess what is going wrong ? And what you are expecting ?

          kk.in wrote:

          ios::app | ios::in

          You know that you will only be able to read the file (and I don't know why you used ios::app here, this is only usefull when writing to the file).


          Cédric Moonen Software developer
          Charting control [Updated - v1.1]

          K Offline
          K Offline
          kk tvm
          wrote on last edited by
          #4

          Hi The real problem is I have a text file with some data, I want to edit data from a particular position,it without using temperory file. I try to edit the data and it will added to end of the file ? thanx

          KK

          C D 2 Replies Last reply
          0
          • K kk tvm

            Hi The real problem is I have a text file with some data, I want to edit data from a particular position,it without using temperory file. I try to edit the data and it will added to end of the file ? thanx

            KK

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            You need to use the ios::out flag if you want to write something to the file (otherwise it is read-only)

            kk.in wrote:

            I have a text file with some data, I want to edit data from a particular position,it without using temperory file.

            You can't do that, you cannot insert data at a certain position (only write on it but you won't be able to insert extra characters).


            Cédric Moonen Software developer
            Charting control [Updated - v1.1]

            1 Reply Last reply
            0
            • K kk tvm

              Hi The real problem is I have a text file with some data, I want to edit data from a particular position,it without using temperory file. I try to edit the data and it will added to end of the file ? thanx

              KK

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

              kk.in wrote:

              I have a text file with some data, I want to edit data from a particular position,it without using temperory file.

              While you can certainly change text (e.g., replace dog with cat)without using a temporary file, you cannot make the file any smaller/larger without using a temporary file (there are a few exceptions to this).


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - 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