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 write in text file

how to write in text file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
2 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.
  • S Offline
    S Offline
    smarty12
    wrote on last edited by
    #1

    hello friends plz tell me that how i can write in a text file from a buffer. and how i can search text file offset so that while writing in a file it shld not rewrite in the same position but it shld write in the position specified. thanx

    N 1 Reply Last reply
    0
    • S smarty12

      hello friends plz tell me that how i can write in a text file from a buffer. and how i can search text file offset so that while writing in a file it shld not rewrite in the same position but it shld write in the position specified. thanx

      N Offline
      N Offline
      NewbieStats
      wrote on last edited by
      #2

      Add ur header: #include "fstream.h" To write to File "Title.txt", at end of file. ofstream a_file ( "Title.txt", ios::ate, ios::app); a_file<< "Data"; a_file.close(); To read from File "Title.txt" char idata[256]; ifstream b_file ( "Title.txt" ); while (! b_file.eof() ) // From beginning to End of File. { b_file.getline(idata,256); cout<< idata < Hope it Helps... Replace the "Title.Txt" or "Data" with a variable and dont use the ""'s and you can have it set by user. Does this help? /* Just a Human Trying to Live in a Computers World. */

      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