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. ostream [modified]

ostream [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 2 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.
  • F Offline
    F Offline
    FredrickNorge
    wrote on last edited by
    #1

    hi, i want to use ostream to write to a txt file, though i dont want it to automaticly start a new txt file, if a text file already excists, but behave similar as : FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f); thanks -- modified at 16:22 Thursday 3rd August, 2006

    Z 1 Reply Last reply
    0
    • F FredrickNorge

      hi, i want to use ostream to write to a txt file, though i dont want it to automaticly start a new txt file, if a text file already excists, but behave similar as : FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f); thanks -- modified at 16:22 Thursday 3rd August, 2006

      Z Offline
      Z Offline
      Zac Howland
      wrote on last edited by
      #2

      FredrickNorge wrote:

      FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f);

      That isn't using ostream ... If you want to use ostream (specifically, ofstream):

      ofstream fout("file.txt", ios::out | ios::app);
      fout << "Hello, world!" << endl;
      

      That will open a file named "file.txt" for output and append "Hello, world!" to the end of the file.

      If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

      F 1 Reply Last reply
      0
      • Z Zac Howland

        FredrickNorge wrote:

        FILE* f=fopen("txt.txt","a"); fwrite(buffer,sizeof(buffer),1,f);

        That isn't using ostream ... If you want to use ostream (specifically, ofstream):

        ofstream fout("file.txt", ios::out | ios::app);
        fout << "Hello, world!" << endl;
        

        That will open a file named "file.txt" for output and append "Hello, world!" to the end of the file.

        If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

        F Offline
        F Offline
        FredrickNorge
        wrote on last edited by
        #3

        thanks , perfect!

        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